runshell question

Started by mueer01, July 07, 2016, 01:35:35 AM

Previous topic - Next topic

mueer01

Hello,

I want to sort a file (c:\tmp\aaa.txt) with the runshell command. If I try this:

runshell("sort", "c:\tmp\aaa.txt", "c:\tmp", @NORMAL, @WAIT)

I see the sorted output scrolling through the DOS box (for a second).
But I need the output sent to c:\tmp\bbb.txt. So I tried this:

runshell("sort", "c:\tmp\aaa.txt > c:\tmp\bbb.txt", "c:\tmp", @NORMAL, @WAIT)

This does not work, I get nothing.

Is it possible at all?

Regards,
Erhard


mueer01

problem solved.

I created a mysort.bat dynamically with the complete sort command in it
then run the mysort.bat file

- close -

td

You don't need to use the command shell's 'sort' command to sort a file with WinBatch and the topic of redirecting command shell stdout to a file is covered multiple time with multiple solutions in the Tech Database.  If you do want to use the command, the following is likely simpler and faster than just redirecting stdout or using a bat file:
Code (winbatch) Select
strCmd = Environment("COMSPEC")
RunShell(strCmd,"/c sort c:\temp\Junk.txt /o c:\temp\sortedjunk.txt", '', @Normal, @Wait)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade