Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Using in background process

by Anonymous Monk
on Sep 28, 2002 at 01:23 UTC ( #201395=perlquestion: print w/replies, xml ) Need Help??

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

I wrote a program that spawns a telnet session and interacts with it using and it works well when run in the foreground in the Bash shell in Solaris 8. The problem happens when I try to run it in the background. The process stops as soon as the telnet session is spawned and does nothing. I have tried messing with the tty settings, changing it to raw and sane but, to no avail. I am using version 1.15 and Perl version 5.6.1. Any suggestions would be greatly appreciated.

Replies are listed 'Best First'.
Re: Using in background process
by jj808 (Hermit) on Sep 28, 2002 at 04:50 UTC
    Have you tried using the Net::Telnet module? It is almost always better (not to mention more portable) to use the Net::* modules to access network services than to try and control external programs.

    However even if you do need to control an external program, I have found Net::Telnet to be more reliable than anyway (just connect to localhost and go from there). I'm not entirely sure why was failing in background processes, but I am using Net::Telnet in the background at the moment (on Tru64 UNIX) with no problems.


      I think you dismiss the Expect modules to early. While Net::Telnet certainly has an impressive featureset, with even patternmatching and timeouts, Expect is even better. In my work as a Test Engineer I found Expect and to be easy to work with.

      According to the documentation, Expect should work on "any modern POSIX Unix", and under Cygwin (but not ActivePerl), which also makes it rather portable.

      However, if the brother doesn't need all the bells and whistles of Expect, your suggestion is an excellent one.

        I guess it's a case of 'once bitten, twice shy'...

        When I was using Expect to control an interactive command process, it occasionally got out of sync - I would send a command, get a truncated response, send another command and get the previous response in full. This was not a timeout or prompt-matching issue. But since replacing Expect with Net::Telnet I have had no problems (famous last words!).

        Maybe it didn't like DEC Compaq HP Tru64 UNIX or DEC AlphaServer hardware?


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2023-01-27 07:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found