How to run executable files ?

Posted by alpaslanyagcioglu on 2011-05-04 07:59

I am trying to write a script which will use "plink.exe" to connect Secure Shell.

I could not find the code to call executable file.
my tcl file name is test.tcl

when I call test.tcl on Tclsh86 by using "tclsh86 test.tcl", it does not work. If I use "c:/Tcl/plink.exe -ssh default@10.6.140.91" only on Tclsh86 by itself it works.

% tclsh test.tcl
invalid command name "tcl"
while executing
"c:/Tcl/plink.exe -ssh default@10.6.140.91"
(file "test.tcl" line 1)
child process exited abnormally

alpaslanyagcioglu | Wed, 2011-05-04 08:38

I found this info.

open |progName ?access?
Returns a file descriptor for the pipe. The progName argument must start with the pipe symbol. If progName is enclosed in quotes or braces, it can include arguments to the subprocess.
exec ?switches? arg1 ?arg2? ... ?argN?
exec treats its arguments as the names and arguments for a set of programs to run. If the first args start with a "-", then they are treated as switches to the exec command, instead of being invoked as subprocesses or subprocess options.

Still i am trying "open |c:/Tcl/plink.exe -ssh default@10.6.140.91"
I get error.

% tclsh ssh_rnc.tcl
expected integer but got "default@10.6.140.91"
while executing
"open |c:/Tcl/plink.exe -ssh default@10.6.140.91"
(file "ssh_rnc.tcl" line 1)
child process exited abnormally
%

alpaslanyagcioglu | Thu, 2011-05-05 09:19

just add exec before the file.

example :

exec c:/Tcl/plink.exe -ssh default@10.6.140.91 -pw !default &