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

how to send special characters in expect script?

$
0
0

I'm trying to send special characters (password) which contains #?!k;|C .The password is dynamic and cannot be hardcoded in the script, so I'm passing it as variable as shown below

$ expect ./passwordlessSSH.exp $hostname "$password"

the code of this script is as below

#!/usr/bin/expect -f set host [lindex $argv 0]set pass [lindex $argv 1]spawn ssh-copy-id -i /home/hdpsvcs/.ssh/id_rsa.pub hdpsvcs@$hostexpect {"yes" {    send "yes\r"  }"assword" {    send "$pass \r"}exit 0

But still it is not running the script properly. I don't see any error but the variable is not passed correctly. The output is as shown below:

$ expect ./passwordlessSSH.exp $hostname "$password" spawn ssh-copy-id -i /home/hdpsvcs/.ssh/id_rsa.pub test@otesthost/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:"/home/test/.ssh/id_rsa.pub"/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are     prompted now it is to install the new keys\SKernel \r on an \mtest@test's password: $

Viewing all articles
Browse latest Browse all 157

Trending Articles



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