From: <gl...@ma...> - 2001-07-24 01:28:32
|
Forwarded message: > From: "Roland Giersig" <Ro...@a1...> > To: gl...@ma... > Cc: exp...@li... > Date: Mon, 23 Jul 2001 17:07:52 +0200 > > > I am trying to do something like this: > > > > $ob=Expect->spawn("rsh machine command arg | localcmd"); > > > > I get the impression that spawn cannot handle the pipeline. > > Right, this is a bug, I will fix it in v1.12, which I'm testing > and preparing for release right now. But due to my pending vacation > it will only be released mid to end of august. > > You can of course just patch your copy of Expect.pm, simply > substitute the "exec(@_)" inside sub spawn with "exec($cmd)". Thanks :) I'm about to try it out... > > I am guessing that I need to do this: > > > > $ob1=Expect->spawn("rsh machine command arg"); > > $ob2=Expect->spawn("localcmd"); > > > > and then use interconnect ....??? > > This is one possiblity, but probably not the best. What is that > localcmd you want to run at the end of the pipeline? > Couldn't you just use qx(rsh machine | localcmd) instead of expect and > then process the output by regular means? I can't imagine > a case where a program within a pipe requires user interaction. > > Oh, maybe rsh is asking for a password? ... Nope. Since you're interested, this is the guts of what I am trying to do: spawn("rsh machine dump_cmd various args... mount-point |cat -|dd bs=64k of=tape-device"); then use expect to catch the message: "End of tape reached. Press RETURN when new tape loaded ..." (message varies depending on the dump software - yes, I'm doing this from multiple machines/OSes/dump commands, each with different idiosyncrasies, arguments, etc...) When I get the expect message, I call a sub to change tapes using the tape robot. That's the plan anyway. :) Glen -- Glen Davison gl...@ma... Computer System Administrator phone: +61 2 9385 7018 Maths, UNSW fax: +61 2 9385 7123 |
From: Roland G. <r.g...@xs...> - 2001-07-24 10:58:16
|
> Since you're interested, this is the guts of what I am trying to do: > > spawn("rsh machine dump_cmd various args... mount-point |cat -|dd bs=64k of=tape-device"); > > then use expect to catch the message: > "End of tape reached. Press RETURN when new tape loaded ..." > (message varies depending on the dump software - yes, I'm doing this > from multiple machines/OSes/dump commands, each with different > idiosyncrasies, arguments, etc...) > > When I get the expect message, I call a sub to change tapes using the > tape robot. That's the plan anyway. :) Oh, OK, that's a perfectly valid use for Expect... :-) BTW, what's the use of that noop-cat inside that pipe? 'dd' already does all the buffering you need... Good luck with that project! Roland -- RGi...@cp... |
From: <gl...@ma...> - 2001-07-25 03:38:48
|
> > > Since you're interested, this is the guts of what I am trying to do: > > > > spawn("rsh machine dump_cmd various args... mount-point |cat -|dd bs=64k of=tape-device"); > > > > then use expect to catch the message: > > "End of tape reached. Press RETURN when new tape loaded ..." > > (message varies depending on the dump software - yes, I'm doing this > > from multiple machines/OSes/dump commands, each with different > > idiosyncrasies, arguments, etc...) > > > > When I get the expect message, I call a sub to change tapes using the > > tape robot. That's the plan anyway. :) > > Oh, OK, that's a perfectly valid use for Expect... :-) > > BTW, what's the use of that noop-cat inside that pipe? 'dd' already does > all the buffering you need... No, unfortunately not. After a great deal of experimenting, we found we needed to do this to get the blocking right. Something to do with buffering and rsh lags perhaps? > Good luck with that project! Thanks. Believe me, I need it! I tried the change to the exec in Expect. Didn't help. Currently I am getting this: Reached end of medium for /dev/nrmt1h; Please wait for file closing Cannot prompt (can't open /dev/tty): No such device or address expect is catching the "Press RETURN ..." message, and happily changing tapes, but the print $bakupcmdobj "\r"; which I do after the tape is ready is evidently failing. The script just hangs - I see this: # ps -fu root | grep ... root 3661 198 0.0 - ?? 0:00.00 <defunct> root 198 12213 0.0 11:14:41 ttyra 0:00.38 perl /usr/local/sbin/bakup_master .... Any thoughts? thanks Glen -- Glen Davison gl...@ma... Computer System Administrator phone: +61 2 9385 7018 Maths, UNSW fax: +61 2 9385 7123 |
From: Roland G. <r.g...@xs...> - 2001-07-25 11:42:42
|
gl...@ma... wrote: > I tried the change to the exec in Expect. Didn't help. Well, it helped insofar as you now can spawn pipe commands, right? > Currently I am getting this: > > Reached end of medium for /dev/nrmt1h; Please wait for file closing > Cannot prompt (can't open /dev/tty): No such device or address Hmm, this sounds bad. 'dd' is trying to read a user response via /dev/tty, over which Expect doesn't have control. interconnect() cannot help here, because as long as 'dd' is reading from stdin, it has to open /dev/tty for a user respone. [earlier programs tried to read from stderr, and this even worked, on some systems... :-) ] Workaround: don't pipe directly into 'dd', use an intermediate file and spawn 'dd' separately. Disadvantage: you need enough harddiskspace. Workaround for that: a named pipe: 'rsh ... > named_pipe' and 'dd if=named_pipe of=/dev/tape' That way, 'dd's stdin stays available for user responses. I do hope that 'dd' is then using stdin and not stubbornly trying to open /dev/tty, otherwise you've got a real problem. > expect is catching the "Press RETURN ..." message, and happily changing > tapes, but the > > print $bakupcmdobj "\r"; > > which I do after the tape is ready is evidently failing. Yes, because it goes to stdin and not to /dev/tty. Hope this helps, Roland PS: Starting tomorrow, I'm off for summer vacation for two weeks. |