Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running gawk from VB6 2

Status
Not open for further replies.

magicme

Technical User
Jun 11, 2003
22
US
hello i am posting this question on both the VB and the awk forums, as i dont know if my error is VB or gawk related.

this is a variation of the question i posted earlier on the awk forum.

if you can, please answer either the VB side of this or the awk (gawk) side of this problem.

i installed gawk successfully on a MS windows XP PC and my awk script runs successully in a command window. however i created a VB6 form to select several file options before executing gawk.

the gawk script is named [airnew.awk], the input file is [for033.dat] and the output file is [junk.out].

my VB6 commands are as follows:

Private Sub rungawk_Click()
Open App.Path & "\junk.out" For Output As #1
comstring = "C:\Program Files\GnuWin32\bin\gawk.exe " & scriptname & " " & strinputfile & " " & "> " & App.Path & "\junk.out"""
rtb1.Text = comstring
Shell comstring, vbNormalFocus
Close #1
End Sub

the resulting command string (printed to a text box to verify syntax) is:
C:\Program Files\GnuWin32\bin\gawk.exe E:\HeatSynch\Codes\gawkrunner\airnew.awk E:\HeatSynch\Codes\gawkrunner\for033.dat > E:\HeatSynch\Codes\gawkrunner\junk.out"

when i click the "rungawk" button, a command window flashes open and closed. the [junk.out] file is created but is left empty.

any guidance would be appreciated.

daveleo




 
You may try this:
Private Sub rungawk_Click()
comstring = """C:\Program Files\GnuWin32\bin\gawk.exe"" -f " & scriptname & " " & strinputfile & " > " & App.Path & "\junk.out"
rtb1.Text = comstring
Shell comstring, vbNormalFocus
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
1. You need a -f command line option to specify that the following file is the program file

[tt]C:\Program Files\GnuWin32\bin\gawk.exe -f E:\HeatSynch\Codes\gawkrunner\airnew.awk E:\HeatSynch\Codes\gawkrunner\for033.dat > E:\HeatSynch\Codes\gawkrunner\junk.out"[/tt]

2. You probably don't need that trailing double-quote at the end of the output filename.

3. Open App.Path & "\junk.out" For Output As #1
Remove this - since you now have the same file opened twice for output (the other being the redirection in the command line).

--
 
PHV
thanks....that runs successfully and scrolls the ouput thru a DOS window ....but gawk is apparently interpreting the " > " symbol to be an input file (that doesnt exist of course), rather than an output redirection to [junk.out]

i will keep hacking....if you have an idea on this new issue....thanks in advance...you have already helped a lot.

daveleo

 
I don't know VB6, so just a guess:
comstring = Environ("COMSPEC") & " /C ""C:\Program Files\GnuWin32\bin\gawk.exe"" -f " & scriptname & " " & strinputfile & " > " & App.Path & "\junk.out"
Environ("COMSPEC")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Salem....thanks for the response.
if you would, see my second message.....gawk is not interpreting the " > " symbol as an output redirection.

i am working on syntax variations now, but would you have an idea on that?

daveleo
 
thanks to all

i ended up creating a VB6 form to select scripts and files and point to executables, etc. and the folks over on the VB6 forum corrected a few stumbling blocks in getting that done.

alls well that ends well.

daveleo

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top