Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Expect script embedded in shell: how to specify value defined in remote shell?

$
0
0

1. Problem description:

I have a script which needs to ssh to an remote server and run some scripts.

But I met some troubles when trying to use values that defined in remote server.

I use "\$" to refer to the value defined in remote server but it says the value is not defined...

2. Error message:

enter image description here

3. Script:

#!/bin/bash  
myusrname="xxx"
myhost="xxx"
mypsword="xxx"

/usr/bin/expect<<-EOF
spawn ssh -o "StrictHostKeyChecking=no" $myusrname@$myhost
expect "*password*"
send "$mypsword\r"
expect "*#*"
send "tst=\"just a test string\"\r"
expect "*#*"
send "echo \$tst\r"
EOF

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>