简体   繁体   中英

awk error while running script using VBA

I have a bash script which works ok when I run it normally (using cygwin window). The code below:

B=$2 #(ie. B="50602_15:56:31_15:56:11_15:56:21")

for line in ${B//;/ } ;
do  
     TENT=`echo ${line} | awk '{split($0,numbers,"_"); print numbers[1]}'`"_sim_fills.txt"
done

Now I am trying to run this script using vba in excel:

Public Sub test()
    Dim cmd As String
    Dim ret As Double
    Dim WshShell As Object
    Dim plink_object As Object

    ' Run Linux Commands
    Set WshShell = CreateObject("WScript.Shell")
    On Error Resume Next
    Set plink_object = WshShell.Run("C:\cygwin\bin\mintty.exe fills_new.sh 66 ""50602_15:56:31_15:56:11_15:56:21;50602_15:57:07_15:56:47_15:56:57""", 1)
    On Error GoTo 0
End Sub

I got an error: " awk: command not found ". Any ideas?

As @BroSlow suggested I used full path to awk and it works ok.

B=$2 #(ie. B="50602_15:56:31_15:56:11_15:56:21")

for line in ${B//;/ } ;
do  
     TENT=`echo ${line} | "/cygdrive/c/cygwin/bin/awk" '{split($0,numbers,"_"); print numbers[1]}'`"_sim_fills.txt"
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM