I use a socket connection in a subroutine that closes after I send a command. The easiest way that I have found to read the text back is using the shutdown ($socket_name, 1). You can then run a while(<$socket_name>){
print $_;
}
to return whatever the prompt/responce is.
Again, for each command that I send, I create a new socket connection send the command and disconnect/kill the socket.
Also once the while loop is in place, you can use a regex to take what you want out, like the prompt, since it is making a new connection everytime.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|