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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exec'ing a batch file

Status
Not open for further replies.

mucklow

Programmer
May 22, 2001
40
US
Hello,
has anyone had experience with running batch files from tcl? I have a .bat file set up for ftp'ing files, and the output of the ftp command pipes to a log file. If I double click the .bat file, it runs fine and the log file reports all the arguments and responses from the ftp command. However, if I run the exact same batch file from a TCL script (exec $the_batch_file), the output is different, it doesn't capture the response from dos, it only reports the arguments. Does anyone know how I can capture both the arguments and responses running the batch file from TCL? I also tried using the ftp command from within the script itself but with the same problem, it doesn't capture the responses.
 
I'm using the following method within a procedure-call far all kinds of executables (*.exe,*.bat,...)
The filename of the executable ( inclusive parameters as a quoted string ) has to assign to "var(fil)"

Results are:
1.) The error-counter $var(flt) (zero means all right)
2.) All the trapped strings from executing shell in $var(log0...log3);
the primary result is in $var(log0), most times it's "mirrored" in $var(log2);
in several times - depending from the command to absolve - the result and/or fault-strings
are read to $var(log3) by executing the "close"-command.

-------------------------------------------------------------------------------

set var(flt) 0
incr var(flt) [ catch { set var(chn) [ open "| $var(fil)" r+ ] } var(log1) ]
incr var(flt) [ catch { set var(log0) [ read -nonewline $var(chn) ] } var(log2) ]
incr var(flt) [ catch { close $var(chn) } var(log3) ]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top