Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Spawn Expect Object in the background doesn't work

by set_uk (Pilgrim)
on Apr 01, 2004 at 14:11 UTC ( [id://341631]=perlquestion: print w/replies, xml ) Need Help??

set_uk has asked for the wisdom of the Perl Monks concerning the following question:

I have a script which successfully uses Expect.pm to spawn telnet sessions. This works great when run in the foreground - but when in the background the script just dies. In the following snippet the code always stops just after "AHEAD OF SPAWN". I guess this is down to IO::TTy and IO::Pty needing a terminal? Can anyone shed any light on this as I dont understand to be even dangerous on this one. Thanks Simon
$self->{_logger}->debug("AHEAD OF SPAWN"); eval { $Spawned = Expect->spawn("$args[0] $args[1]"); $msg = "Spawning to $args[0] $args[1]\n"; $self->{_logger}->info($msg); }; $self->{_logger}->debug("AFTER OF SPAWN");
Found out that the script doesn't die - it just stops and sits there waiting to be brought into the foreground. When it is - it starts again and picks up normal processing

Replies are listed 'Best First'.
Re: Spawn Expect Object in the background doesn't work
by Fletch (Bishop) on Apr 01, 2004 at 14:43 UTC

    You might get more enlightenment if you check if the spawn call is returning an error or not, printing out $! if it's not.

      Found out that the script doesn't die it just stops processing until it is back in the foreground
Re: Spawn Expect Object in the background doesn't work
by TilRMan (Friar) on Apr 02, 2004 at 12:37 UTC
    It might be the way your shell handles background jobs. Try running the script under nohup(1).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://341631]
Approved by Thelonius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found