 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
JJ
Joined: 11 Oct 2005 Posts: 6
|
|
Redirect output to file |
|
I am trying to execute a simple command-line application and redirect the output to a file (e.g. foo.exe >> output.txt). When I try to schedule this with 27x7, it fails to create the file. I have tried a simple "Run program or document file", specifying the command line as "foo.exe >> output.txt" and I have also tried the "Run Script" option with the JAL script Dim process_id, number RunAndWait ("foo.exe >> output.txt", "", 30, process_id) This script is based on a built-in example, but I still don't get the output.txt file created. What could be wrong here?
|
|
Thu Oct 13, 2005 10:49 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7964
|
|
Re: Redirect output to file |
|
Is foo.exe is console application? If this is a graphical application don't expect anything in the output if it doesn't write to console. : I am trying to execute a simple command-line : application and redirect the output to a file : (e.g. foo.exe >> output.txt). When I try to schedule : this with 27x7, it fails to create the file. I have : tried a simple "Run program or document file", specifying : the command line as "foo.exe >> output.txt" and I have : also tried the "Run Script" option with the JAL script : Dim process_id, number : RunAndWait ("foo.exe >> output.txt", "", 30, : process_id) : This script is based on a built-in example, but I : still don't get the output.txt file created. : What could be wrong here?
|
|
Thu Oct 13, 2005 1:04 pm |
|
 |
JJ
Joined: 11 Oct 2005 Posts: 6
|
|
Re: Redirect output to file |
|
Yes, it's a simple console application that writes a string to the console, so if I go to a DOS prompt and enter > foo.exe I get > The date is mm/dd/yy If I enter >foo.exe >> output.txt I get text file named output.txt with the previous text in the file. : Is foo.exe is console application? If this is a graphical application don't : expect anything in the output if it doesn't write to console.
|
|
Thu Oct 13, 2005 1:43 pm |
|
 |
JJ
Joined: 11 Oct 2005 Posts: 6
|
|
Re: Redirect output to file |
|
I just got it to work (kind of). If I create a batch file that looks like this: @echo off foo.exe and I execute the batch file instead of the command itself, it does what I want it too. Still, it would would be nice if there was a way to not have to create a batch file for every command I want to execute this way.
|
|
Thu Oct 13, 2005 1:53 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7964
|
|
Re: Redirect output to file |
|
Where have you searched for output.txt? Have you tried single ">" instead of a ">>"? Dim process_id, number RunAndWait ("foo.exe > output.txt", "", 30, process_id) You can also try Dim process_id, number RunAndWait ("cmd /B foo.exe > output.txt", "", 30, process_id) : Yes, it's a simple console application that writes : a string to the console, so if I go to a DOS prompt : and enter : I get : If I enter : I get text file named output.txt with the previous text : in the file.
|
|
Thu Oct 13, 2005 1:54 pm |
|
 |
JJ
Joined: 11 Oct 2005 Posts: 6
|
|
Re: Redirect output to file |
|
: Where have you searched for output.txt? I've looked in the "Start In" folder, the folder where the exe resides, and in the 24x7 folder (and subfolders) : Have you tried single ">" instead of a ">>"? Just tried it, with no luck either in command-line or script. Thanks for the suggestions
|
|
Fri Oct 14, 2005 4:03 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7964
|
|
Re: Redirect output to file |
|
What about "cmd /B foo.exe > c:\output.log" Have you tried that? : I've looked in the "Start In" folder, the folder : where the exe resides, and in the 24x7 folder (and : subfolders) : Just tried it, with no luck either in command-line : or script. : Thanks for the suggestions
|
|
Fri Oct 14, 2005 4:50 pm |
|
 |
JJ
Joined: 11 Oct 2005 Posts: 6
|
|
Re: Redirect output to file |
|
Yes, that just makes a command window pop up, but doesn't actually run the executable. : What about "cmd /B foo.exe > c:\output.log" Have you tried that?
|
|
Mon Oct 17, 2005 2:27 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7964
|
|
Re: Redirect output to file |
|
Make your executable to write something or at least put it into a batch file that has "pause" command at the end, for example, ;this is foo.bat foo.exe > c:\output.log pause In the job properties enter foo.bat or cmd /B foo.bat. The result sould be the same. When foo complets the DOS command window will remain open untill you press a key. : Yes, that just makes a command window pop up, but : doesn't actually run the executable.
|
|
Mon Oct 17, 2005 2:53 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|