0
I'm trying to set a variable in a Linux bash script which includes a $
symbol, i.e. password is Gl@d1us$123 so PASS="Gl@d1us\$123"
. I can preceed the $
with a \
and it works fine, but when it calls the EXPECT script the $
symbol causes it to fail. I can enter the password directly into the EXPECT script using the \
as before and it works fine, so it's just the process of passing the password variable between scripts that is causing me grief.
Main script:
echo
echo
USER=kendalla
PASS="Gl@d1us\$123"
DIR=/home/kendalla/scripts/Audit
./get_hardware.expect $HOST $USER $PASS > $DIR/$HOST
get_hardware.expect script:
#!/usr/bin/expect -f
log_user 1
log_file /home/kendalla/scripts/Audit/HOST
set HOST [lrange $argv 0 0]
set USER [lrange $argv 1 1]
set PASS [lrange $argv 2 2]
spawn ssh -q -l $USER $HOST
expect "$USER@rebehc01's password:"
send "Gl@d1us\$123\r" ;#(This works)
send $PASS ;#(This doesn't work)
All help appreciated.
Thanks
Andy.
1Show some code. It can be readily solved. – glenn jackman – 2014-05-14T16:42:03.197
Code appended as requested. – Andy Kendall – 2014-05-15T07:57:06.113