From: Roland G. <RGi...@cp...> - 2004-06-14 11:15:02
|
> Here=92s my problem. I spawn a ssh session to a remote box, and run a=20 > command. If the command is successful, I just get a new prompt, but i= f > it fails, the program spits out an error on STDERR. Currently,=20 > $exp_object->exp_before(),$exp_object->match(), and my=20 > $exp_object->exp_after() objects contain all the STDOUT info, but no=20 > STDERR info. How does one trap the STDERR strings? What fails? The ssh shell connection? Or the remote call? Expect=20 definitely gets everything that ssh returns on both STDOUT and STDERR.=20 It may miss things to /dev/tty on some systems in certain circumstances. > On a side note, is there a simple way to get the bash return code from = a=20 > command sent to a spawned ssh shell? Right now I=92m doing a =93echo $= ?=94=20 > and expecting =93\d\r=94 and parsing the string in $exp_object->match()= ; If the ssh is interactive, no. Keep using "echo $?". A one-shot ssh=20 command will correctly exit with the exit status of the remote command=20 (but you wouldn't use Expect then, would you?) Have you considered solving your problem by other means? Is the remote=20 app really interactive or could it also be run in a batchfile? How about=20 moving the Expect script to the remote host and running it there? Roland |