I have written a unix expect utility "ssh-login.exp" which connects (ssh) to remote host and execute some shell script. I am calling this "ssh-login.exp" utility from another shell script.
"ssh-login.exp" takes username, password, host and shell script path to execute on remote host. All works fine for alphanumeric passwords. If password contains special characters e.g. "$", "ssh-login.exp" doesn't work. I have already added logic to add escape character right before any special characters in password string.
e.g. for password string "welcome$123" and I send "welcome\$123".
The issue is when expect utility "ssh-login.exp" sends password to remote host, it prepends '{' and appends '}' to password string if password contains any special characters. if password doesn't have any special characters then it sends password without '{' and '}' and works fine.
e.g. for password "welcome$123" expect program sends "{welcome\$123}", in fact it should send "welcome\$123" (without '{' and '}' ). If password is "{welcome\$123}" remote machine don't allow the entry because of wrong password as it is '{' and '}'.
So I am trying to find out a way to get rid of '{' and '}' from password string before sending it to remote host if password contains any special characters.
Here is my expect script : "ssh-login.exp":
Please let me know if someone has already faced this issue and were able to resolve it.
Thanks,
Last edited by Mahesh Desai; 09-25-2014 at 02:26 PM..
Hi
I need to install expect in redhat.
through net I came to know that I must install tcl too in order to make expect work.
I have downloaded both packages but not able to install
# ls -lrt
total 3720
18:33 tcl8.4.20-src.tar.gz
18:33 expect5.45.3.tar.gz
18:40 expect5.45.3... (7 Replies)
Hi Gurus,
I have a file contains special character.
when using:
grep 'xxxxx' filename,
it returns whole line.
when using:
grep -evt 'xxxxx' filename
it returns whole line with special charactor.
when running command:
nl filename |grep 'xxxxxx'
the line break by the special... (1 Reply)
Hello,
I write a TCL script for Expect/ Telnet.
I want to send command to the telnet server.
But I want to close after the command is sent.
Anybody know which command can flush the expect so I can sure the command is sent to the telnet server???
EX:
send "./command1\r"
close... (0 Replies)
hi, I am new in Expect.
I have a question about expect timeout.
suppose I have a structure of
expect { ".."{
send"............"}
timeout{
...............
}
}
The silly question is if I reach timeout, how can I store the error message showing on the screen to... (2 Replies)
Can someone identify what is the problem here?.
no children
while executing
"exp_wait -nowait -i -1"
(procedure "logOptions" line 45)
invoked from within
"logOptions"
(procedure "doExecute" line 98)
invoked from within
"doExecute"
(procedure "main" line 32)
... (7 Replies)
In the following "for" loop I assume the the script will expect "anyway", "first" NOT in any paticular order and send "yes" when there found, breaking out of the loop when "$prompt" is found. The way it is working is like 3 individual expect lines, and they MUST be in cronological order. ANY help... (0 Replies)
Hello Experts,
Can someone help me here:
I have a variable which contains a string with "".
set var1 {a}
set str1 {a is the element i want to match}
Now "regexp $var1 $str1" does not work?
("regexp {a\} $str1" works, but var1 gets it's value automatically from another script)
Is... (6 Replies)
Does anyone know of an expect/tcl forum that is as helpful as this one is for shell scripting?
Or if anyone has any expect knowledge, can you please provide some guidance on how to write to a local error log based on output from a ssh session?
I have something like this:
foreach host... (2 Replies)
Hi,
I've an xml file with special characetr 'TM' (trade mark sign). The issue is that I am not able to get the symbol 'TM'(trade mark sign) on unix. It displays '?' instead. I've searched the solution on net. Wht I've found is that the symbol 'TM' does not come under ISO-8859-1 char set. So I... (0 Replies)
hai all,
i have an tcl script in which i have been reading the DUT Command prompt of an cisco switch as
DUT Command Prompt : cisco*
and running the test case of stp now the problem is if i have given any blank space in between the cisco or at the startup then the Expect is not identifying the... (0 Replies)