Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ TCL escape characters

Posted by: gustavolinux Oct 20 2008, 01:22 PM

Folks, I'm having a problem with a tcl escape character: the backslash.

I'm trying to create a script that calls another script. One of the parameters that is sent to the other script is a password (to use with ssh). Well, if the password is a usual string, like 'carrie', it works fine. The problem occurs when the first letter of the password is a dollar sign, like $testpass. When this password is used, tcl seems to write the string inside braces, like {$testpass}. This new value created by tcl is sent to the second script, and then my system fails, because the correct password is $testpass, and not {$testpass}.

Please, somebody that knows tcl can help me?

A simple teste code shows my problem:


package require Expect

set timeout 15

set ssh_password \$testpass

spawn ./ 5622 root $ssh_password md5sum /root/ipt-firewall


Debugging, I found that the parameters given to spawn by tcl engine was:

./ 5622 root {$testpass} md5sum /root/ipt-firewall

Where the incorrect password appears... It should be $testpass.

Thanks by the attention dudes...

Posted by: gustavolinux Oct 21 2008, 12:51 PM

I'll make the test more simple, than I can explain it perfectly...

There is two files: and code is:


package require Expect

set timeout 15

set ssh_password \$teste

spawn ./ $ssh_password

and is:

#!/usr/bin/expect -f
# set Variables

set timeout -1

log_user 0

send_user "\nTeste:\n"
send_user $argv
send_user "\n"

I save both in the same folder and type the following command:

tclsh ./

The output that I get is:
spawn ./ $teste


And it should be


Hope you folks can reproduce now... Thanks by the attention...

Powered by Invision Power Board (
© Invision Power Services (