Re: How to catch erro from spawned command?



Sorry I hit the wrong key and the message just got sent. Here is a
rewrite:

I have a problem with this in expect:
spawn ssh f...@xxxxxxxxxxxxxxx ls -l > /tmp/mylog 2>&1
while (1) {
expect timeout { puts "get timeout\n"; exit 99} \
"Are you sure*" { send "no\r"; break; } \
"*password: $" { send "$passwd\r"; continue; } \
eof { puts "get eof\n"; break;} \
default { puts "get default\n"; break;};
}

The problem is if "ssh" failed, like the script get a dummy ip
address, the erro message, "ssh: connect to host 123.123.123.123 port
22: No route to host" didn't get to /tmp/mylog. This is because
expect think my command is
'spawn ssh f...@xxxxxxxxxxxxxxx "ls -l > /tmp/mylog 2>&1" '
but what I really want is
'spawn "ssh f...@xxxxxxxxxxxxxxx ls -l" > /tmp/mylog 2>&1 '
so I can catch the ssh error.

How should I correct tghe command syntax?

Eric.

.



Relevant Pages

  • Re: How to make "halt" (etc) available for ordinary user
    ... > can ssh in, otherwise you just have to hit the power switch. ... I do not like to stop and restart hard drives, ...
    (comp.os.linux.misc)
  • Re: friendly scp (help)
    ... Use mc and ssh. ... Then hit "E" for New Entry. ... There should now be an entry in your hotlist. ... your remote box on the other side, ...
    (Debian-User)
  • Re: (quickie) print in place?
    ... > I notice though that that if you hit a key while it's looping (logged ... > into ssh), it shifts the whole thing over, then the next itereation ...
    (comp.lang.perl.misc)
  • Re: 2.6.25-rc8-mm2: IP: [] __kmalloc+0x69/0x110
    ... box here for far too long, and hit below. ... What happened if freshly booted box (probably not all init scripts finished), ... ssh from another box and reboot from session. ... but it won't help this crash. ...
    (Linux-Kernel)
  • Cygwin ssh exits when I hit ctrl+c in a shell over a slow connection
    ... I can ssh in, then run something like 'tail -f logfile'. ... terminate the tail -f, I hit 'ctrl+c'. ... This terminates my shell! ... ssh out to RedHat boxes all of the time! ...
    (comp.security.ssh)