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

Oh wise ones, I can't paste any code as it's work related, but here is my issue. I have written a simple webpage using perl.
What the page does is I paste xml data into a textbox, then using Net::Telnet I'm trying to establish a connection with another server and paste the xml data as the argument.
Now the page 'hangs' and times out. The timeout line is: $session->getline.
When I run the same code from the command prompt, it works flawlessly and I get my output from the session, but not when I run it within my webpage code.
Any help would be greatly appreciated.

The process flow is as follows:
Paste xml data to textbox.
Pass xml data to telnet session, wait for output string.
The telnet session is simple as I have a process listening on a port on another server. As soon as the process receives the xml data, it returns a string.
Thanks, desperate

Replies are listed 'Best First'.
Re: Telnet issues
by SuicideJunkie (Vicar) on Aug 17, 2007 at 20:39 UTC

    I had the same problems when I tried something vaguely similar.

    Reads are blocking, so if the input ends unexpectedly, you're stuck. Try using the select http://perldoc.perl.org/functions/select.html function to test whether there is any data to read, and nibble the input one character at a time. If your input terminates without a \n then you'll time out the select instead of reading blindly and getting stuck.

Re: Telnet issues
by blue_cowdawg (Monsignor) on Aug 17, 2007 at 21:05 UTC
        The telnet session is simple as I have a process listening on a port on another server.

    Have you looked at Net::Telnet perchance?


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg