I tried this with expect, but it didn't work: it closed the connection at the end.
Can we run a script via ssh which will log into remote machines, run a command, and not disconnect?
So ssh in a machine, cd to such and such a directory, and then run a command, and stay logged in.
(expect I used)
#!/usr/bin/expect -f set password [lrange $argv 0 0] spawn ssh root@marlboro "cd /tmp; ls -altr | tail" expect "?assword:*" send -- "$password\r" send -- "\r" interact