I am writing a small script using expect command to supply the password; the aim is to login to a switch and fetch a command. OS : RHEL 7. There is a small app proxychains which is used to login to client network. So I would need to open it first and then run my commands (ssh etc).
[ram@abcde scripts]$ /usr/bin/proxychains ssh firstname.lastname@example.org ProxyChains-3.1 (http://proxychains.sf.net) |S-chain|-<>-184.108.40.206:1080-<>-220.127.116.11:1080-<><>-10.49.99.49:22-<><>-OK email@example.com's password:
I want to automate the above using expect, so I have below script and getting errors.
set user "admin" set password "sample123" /usr/bin/proxychains ssh $firstname.lastname@example.org expect "ssword: " send "$password\r" expect ">\r" send "switchshow\r" expect eof
I am getting below error;
[ram@abcde scripts]$ sh br1.sh usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q cipher | cipher-auth | mac | kex | key] [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command] br1.sh: line 3: ProxyChains-3.1: command not found couldn't read file "ssword: ": no such file or directory br1.sh: line 5: send: command not found couldn't read file ">\r": no such file or directory br1.sh: line 7: send: command not found couldn't read file "eof": no such file or directory