I'm new to scripting and need some help. I am creating an expect script that from a Linux server, that will automatically
ssh/log in to our HP StoreOnce Appliance
#!/usr/bin/expect -f set password "password" match_max 1000 spawn ssh -o StrictHostKeyChecking=no email@example.com expect "*?assword:*" send -- "$password\r" send -- "\r" interact
When executing this script, I was able to automatically login and from there I can type the commands.
Please see output below:
================================================================= [root@dpis tmp]# ./test.exp spawn ssh -o StrictHostKeyChecking=no firstname.lastname@example.org Password: Last login: Thu Jan 26 08:37:24 2017 from 10.x.x.x Welcome to the HP StoreOnce Backup System Command Line Interface. Type 'help' at the prompt for context-sensitive help. >
But what I want to achieve is for the script to not only automatically log-in but also automatically put a command and show its output then exit.
I tried to add the following lines below after interact
expect ">" send -- "serviceset show status"
Seeking assistance on how to achieve this? Thanks!