Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default run awk95 using Shell()

I have an awk script to process a text file before importing it. The script
strips rows from the text file after hitting a line containing only " ".

This works from the DOS prompt in c:\filepath\:
c:\filepath\awk95 "/^ $/{nextfile} 1" c:\filepath\input.txt
c:\filepath\output.text

The following does not work:
strAWKCommandLine = _
"c:\filepath\awk95 " & Chr(34) & "/^ $/{nextfile} 1" & Chr(34) & "
c:\filepath\input.txt c:\filepath\output.text"

Shell(strAWKCommandLine,1)

Another question:
While debugging this, how can I keep the DOS window open so I can see any
error messages?

An example I saw used "/k" :
Shell(Environ$("comspec") & " /k yourfile.bat", vbNormalFocus)

I can't get that code structure to work.

Thanks for any help on using Shell or keeping the DOS window open

Larry Mehl






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default run awk95 using Shell()

Larry,

This worked for me:

Put "input.txt" and "awk.exe" in the root directory of C:
Put these lines in a .bat file called "awk.bat" and put the bat file in the
root directory of C:

C:
cd\
awk95 "/^ $/{nextfile} 1" input.txt output.txt

Then make a macro with these lines and run it:

Sub Tester()
ChDrive "C"
ChDir "C:\"
Shell ("awk.bat")
End Sub

(But you really don't need to do this strip operation).

HTH,
Shockley


"L Mehl" wrote in message
...
I have an awk script to process a text file before importing it. The

script
strips rows from the text file after hitting a line containing only " ".

This works from the DOS prompt in c:\filepath\:
c:\filepath\awk95 "/^ $/{nextfile} 1" c:\filepath\input.txt
c:\filepath\output.text

The following does not work:
strAWKCommandLine = _
"c:\filepath\awk95 " & Chr(34) & "/^ $/{nextfile} 1" & Chr(34) & "
c:\filepath\input.txt c:\filepath\output.text"

Shell(strAWKCommandLine,1)

Another question:
While debugging this, how can I keep the DOS window open so I can see any
error messages?

An example I saw used "/k" :
Shell(Environ$("comspec") & " /k yourfile.bat", vbNormalFocus)

I can't get that code structure to work.

Thanks for any help on using Shell or keeping the DOS window open

Larry Mehl






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default run awk95 using Shell()

Shockley --

Thank you for reminding me of that technique.

My names "input.txt" and "output.txt" will change, depending on a user
selection, so I will revise your suggestion slightly, by writing the bat
file in my code for each different user selection, and then running it from
the code.

I appreciate your help in this project.

Larry


"shockley" wrote in message
...
Larry,

This worked for me:

Put "input.txt" and "awk.exe" in the root directory of C:
Put these lines in a .bat file called "awk.bat" and put the bat file in

the
root directory of C:

C:
cd\
awk95 "/^ $/{nextfile} 1" input.txt output.txt

Then make a macro with these lines and run it:

Sub Tester()
ChDrive "C"
ChDir "C:\"
Shell ("awk.bat")
End Sub

(But you really don't need to do this strip operation).

HTH,
Shockley


"L Mehl" wrote in message
...
I have an awk script to process a text file before importing it. The

script
strips rows from the text file after hitting a line containing only " ".

This works from the DOS prompt in c:\filepath\:
c:\filepath\awk95 "/^ $/{nextfile} 1" c:\filepath\input.txt
c:\filepath\output.text

The following does not work:
strAWKCommandLine = _
"c:\filepath\awk95 " & Chr(34) & "/^ $/{nextfile} 1" & Chr(34) & "
c:\filepath\input.txt c:\filepath\output.text"

Shell(strAWKCommandLine,1)

Another question:
While debugging this, how can I keep the DOS window open so I can see

any
error messages?

An example I saw used "/k" :
Shell(Environ$("comspec") & " /k yourfile.bat", vbNormalFocus)

I can't get that code structure to work.

Thanks for any help on using Shell or keeping the DOS window open

Larry Mehl






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default run awk95 using Shell()

Larry,

It may help you to know that you can variablize the input/output filenames
and change the bat file programatically in vba by doing something like:

Sub WriteBat()
ChDrive "C"
sInputFileName = "Input1.txt"
sOutputFileName = "Output1.txt"
sBat = _
"C:" & vbCrLf & _
"cd\" & vbCrLf & _
"awk95 " & Chr(34) & "/^ $/{nextfile} 1" & Chr(34) & _
" " & sInputFileName & " " & sOutputFileName

Open "C:\awk.bat" For Output As #1
Print #1, sBat
Close #1
End Sub

Regards,
Shockley


"L Mehl" wrote in message
...
Shockley --

Thank you for reminding me of that technique.

My names "input.txt" and "output.txt" will change, depending on a user
selection, so I will revise your suggestion slightly, by writing the bat
file in my code for each different user selection, and then running it

from
the code.

I appreciate your help in this project.

Larry


"shockley" wrote in message
...
Larry,

This worked for me:

Put "input.txt" and "awk.exe" in the root directory of C:
Put these lines in a .bat file called "awk.bat" and put the bat file in

the
root directory of C:

C:
cd\
awk95 "/^ $/{nextfile} 1" input.txt output.txt

Then make a macro with these lines and run it:

Sub Tester()
ChDrive "C"
ChDir "C:\"
Shell ("awk.bat")
End Sub

(But you really don't need to do this strip operation).

HTH,
Shockley


"L Mehl" wrote in message
...
I have an awk script to process a text file before importing it. The

script
strips rows from the text file after hitting a line containing only "

".

This works from the DOS prompt in c:\filepath\:
c:\filepath\awk95 "/^ $/{nextfile} 1" c:\filepath\input.txt
c:\filepath\output.text

The following does not work:
strAWKCommandLine = _
"c:\filepath\awk95 " & Chr(34) & "/^ $/{nextfile} 1" & Chr(34) & "
c:\filepath\input.txt c:\filepath\output.text"

Shell(strAWKCommandLine,1)

Another question:
While debugging this, how can I keep the DOS window open so I can see

any
error messages?

An example I saw used "/k" :
Shell(Environ$("comspec") & " /k yourfile.bat", vbNormalFocus)

I can't get that code structure to work.

Thanks for any help on using Shell or keeping the DOS window open

Larry Mehl






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.600 / Virus Database: 381 - Release Date: 2/28/2004




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell to MSAccess Charles Excel Programming 0 February 18th 04 02:50 PM
xp shell command using vba Sudhendra Excel Programming 2 February 16th 04 05:56 AM
Shell Joseph[_12_] Excel Programming 1 February 1st 04 04:33 AM
shell out of excel into another app toothfish__[_2_] Excel Programming 0 January 19th 04 03:02 PM
SHELL command Robin Clay[_3_] Excel Programming 3 October 17th 03 02:50 PM


All times are GMT +1. The time now is 04:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"