TCL problem. Can someone help?

Steven W. Orr steveo at syslang.net
Thu Nov 4 11:30:50 EDT 2010


I have a stupid question in tcl that I'm just not getting. I'm hoping to get 
lucky here.

I have a script in tcl/expect that spawns su and needs to pass its arguments 
to su.

argv in tcl has the command line args. I lop off the first couple of args that 
I need in my script via:

set user [lindex $argv 0]
set passwd [lindex $argv 1]

Then I want to pass the *rest* of the args to su. What I have is this:

spawn su - $user -c "[lrange $argv 2 end]"

If I call me script

sss me secret 'pwd; ls'

Then what happens is this:

spawn su - swagent -c {pwd; ls;}
Password:
-bash: -c: line 0: syntax error near unexpected token `}'
-bash: -c: line 0: `{pwd; ls;}'

I vershtumped about where the braces are coming from. found out that if I pass 
a single command without any semicolon , it works ok.

I also found that if I pass multiple commands, then it works if the variable 
that contains the commandlist must have a preceding space. e.g.

foo=' pwd;ls;'
sss me secret "$foo"

Is there a proper way to write the tcl script so that it passes throuhg just 
what I send it?

TIA

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


More information about the gnhlug-discuss mailing list