Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error message with Telnet: login failed: filehandle isn't open 1

Status
Not open for further replies.

gilshalev

Programmer
Jan 8, 2008
6
IL
Hi
I run Perl (Using QTP), creating a Telnet object and logging in.
On some PCs it's OK, but on some I get a response:
login failed: filehandle isn't open

Please assist...

Thanks,
Gil
 
Code?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Hi Travs69
It runs on some PCs so doesn't seem that code is the problem.
This is the code:
use strict;
use Net::Telnet;
use File::path;
#use warnings;

my $Server=$ARGV[0];
my $username=$ARGV[1];
my $password=$ARGV[2];
my $sCommand=$ARGV[3] . ";echo Auto_Done";
my $expectedprompt=$ARGV[4];
my $timeoutforsync=$ARGV[5];

if($expectedprompt eq "")
{
$expectedprompt="Auto_Done";
}

my $FILE_NAME = 'c:/test.txt';

my %enterarr;

my $t = new Net::Telnet (Timeout => 30,Port=>23,Host=>$Server,Errmode=>'return');

my %cmdArr=("Name"=>$username, "Password"=>$password, "Prompt"=>"/>/", "Timeout"=>$timeoutforsync, Errmode=>'return');
my $ok=$t->login(%cmdArr);
my $msg = $t->errmsg;
if($msg ne "")
{
open (my $fh,">",$FILE_NAME) or die "could not open '$FILE_NAME'\n";
print $fh ("UNIX ERROR\n");
print $fh ("Message returned from UNIX: \n");
print $fh ("$msg");

close($fh);
exit;
}
 
my $t = new Net::Telnet (Timeout => 30,Port=>23,Host=>$Server,Errmode=>'return') || die "Could not connecto to $Server:$!\n";

and

my $ok=$t->login(%cmdArr) || die "Could not login into $Server:$!\n";

and see if that gets you a little closer to your problem.

Is there a reason you are surrounding all your print statements with ()?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Hi

Thanks, I'll try.

The reason I use () is just that I'm quite new in Perl and used to it from other languges...

Gil
 
Let me know if you get some different error message though. It would be intersting to see what is going on.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top