CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Problem passing telnet connection to function: Edit Log



DanB
New User

Feb 25, 2013, 1:07 AM


Views: 450
Problem passing telnet connection to function

Hi to everyone and pleased to meet you all!

I have a problem passing a telnet connection to sub.

I don't have any problem if I create the connection and then use it, like this


Code
my $conn = Net::Telnet->new(Fhopen => $socket); 
$conn->print($command.(chr 13));
$conn->recv($data, 1024);
# OK!


but if I try to pass the connection to a subroutine like this


Code
 
my $conn = GetConnection(...);
RunCommand($conn, $command);

sub GetConnection
{
...
my $conn = Net::Telnet->new(Fhopen => $socket);
return $conn;
}

sub RunCommand
{
my $conn = shift;
my $command = shift;
$conn->print($command.(chr 13));
$conn->recv($data, 1024);

# NOTHING!!!!
}


it doesn't work: don't do anything.

Any ideas?

Thank you for support


(This post was edited by DanB on Feb 25, 2013, 1:12 AM)


Edit Log:
Post edited by DanB (New User) on Feb 25, 2013, 1:12 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives