Hi Perl Gurus,
___________________________________________________________
Here is what I want to DO:
I am trying to telnet to a server and after authenticating myself, I am trying to write the output to a page
-----------------------------------------------------------
___________________________________________________________
Part of my code:
my $host = shift || $hostName;
my $port = shift || 23;
my $sock = new IO::Socket::INET(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp');
if($sock) # if successfully connected
{
# send message to server
print $sock "xxxxxxx\n"; #sending the userName
print $sock "xxxxx\n"; # sending the password
print $sock "command\n"; # command that i want to execute
open(IN,$fileToWrite); # open the file to write
#Want to loop until the end of data received
while (<$sock>)
{
$line = $_;
print IN $line; # write it to file
}
close(IN);
close $sock or die "close: $!";
}
-----------------------------------------------------------
Problem I am FACING:
When I try to run it, It does not finish printing out to the text file. It stops after Password: Here is the output
-------------------------------------------------
Use of this system by unauthorized persons or in an
unauthorized manner is strictly prohibited.
username: XXXXXX
Password:
-------------------------------------------------
It just ends here.The rest of the data never gets printed
Can some one tell me what to do?
Thanks a lot for your time
___________________________________________________________
Here is what I want to DO:
I am trying to telnet to a server and after authenticating myself, I am trying to write the output to a page
-----------------------------------------------------------
___________________________________________________________
Part of my code:
my $host = shift || $hostName;
my $port = shift || 23;
my $sock = new IO::Socket::INET(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp');
if($sock) # if successfully connected
{
# send message to server
print $sock "xxxxxxx\n"; #sending the userName
print $sock "xxxxx\n"; # sending the password
print $sock "command\n"; # command that i want to execute
open(IN,$fileToWrite); # open the file to write
#Want to loop until the end of data received
while (<$sock>)
{
$line = $_;
print IN $line; # write it to file
}
close(IN);
close $sock or die "close: $!";
}
-----------------------------------------------------------
Problem I am FACING:
When I try to run it, It does not finish printing out to the text file. It stops after Password: Here is the output
-------------------------------------------------
Use of this system by unauthorized persons or in an
unauthorized manner is strictly prohibited.
username: XXXXXX
Password:
-------------------------------------------------
It just ends here.The rest of the data never gets printed
Can some one tell me what to do?
Thanks a lot for your time