I am unable to run commands on remote host using expect script.It just logs in to the remote host and exits.Here is the code
#!/usr/bin/expect
set timeout 15
puts "connecting to the storage\n"
set user [lindex $argv 0]
set host [lindex $argv 1]
set pass "root123"
spawn ssh "$user\@$host"
expect {
"Password: " {
send "$pass\r"
sleep 1
expect {
"$ " {
send "isi quota quotas list|grep ramesh\r" }
"$ " {
send "exit\r" }
}
}
"(yes/no)? " {
send "yes\r"
expect {
"$ " { send "ls\r" }
"$ " { send "exit\r" }
"> " {}
}
}
default {
send_user "login failed\n"
exit 1
}
}
It only gets into the remote host and exits. [deep@host1:~]$ ./sshexpect user1 host2 connecting to the storage
spawn ssh user1@host2
Password:
host2$
[deep@host1:~]$
Is the syntax wrong? I am new to tcl scripting.