Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Getting a response from a socket

by 7stud (Deacon)
on Feb 13, 2013 at 23:50 UTC ( #1018661=note: print w/ replies, xml ) Need Help??


in reply to Getting a response from a socket

Both of these lines:

$socket->getline; my $output = <$socket>;

...read 'line oriented' input, i.e. they return when they read a newline from the socket. So if you want to read all the lines from the socket, you can use one of these:

while ( defined( my $line = $socket->getline ) ) { } while (my $line = <$socket>) { } my @lines = <$socket>;

The script either hangs or it just returns the "Welcome to device 'devicename', please input your commands".

Well, then it sounds like you should start your program by reading a line at a time from the socket--until the line you read matches that text, then send your command. Then read some more lines for the response.


Comment on Re: Getting a response from a socket
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018661]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-06 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls