Ask a Question related to PERL Modules, Design and Development.
-
kishore.konjeti@gmail.com #1
getting output of telnet from perl script
hi all,
i had written a code to connect to unix server from Windows xp where i
installed perl.
i have to do with telnet. I think I am able to connect with unix
server. but i am not able to get out put from the server. i have tried
with 'ls' and 'who' commands. it is giving output
"connectedlogged inBefore ls".
The code is :
use Net::Telnet;
# instantiate a new CGI object
my $telnet = new Net::Telnet(Timeout => 10,
Errmode => 'die');
$telnet->open("servername") or die "hai $telnet->errmsg ";
print "connected";
$telnet->waitfor('/login: $/i');
$telnet->print("ixlourd") or die $telnet->errmsg;
$telnet->waitfor('/password: $/i');
$telnet->print("qwest1") or die $telnet->errmsg;
print "logged in";
$telnet->waitfor('/ixlourd\@e2epia2: $/');
print "Before ls";
$telnet->print('who');
$telnet->waitfor('/ixlourd\@e2epia2: $/');
#$output = $telnet->waitfor('/\$ $/i');
print $output;
@lines=$telnet->print("ls") or die $telnet->errmsg;
print @lines;
OUTPUT:
"connectedlogged inBefore ls".
I have copied telnet.pm module from CPAN to perl directory. why it is
not giving any output of 'ls' . it is simply it is giving
"connectedlogged inBefore ls"
How can i make check whether it is connected to my unix server
successfully.
kishore.konjeti@gmail.com Guest
-
getting output of telnet from perl
hi i had written code to connect to unix server from Windows xp(telnet) where i installed perl. i have to do with telnet. I think I am able to... -
Net::Telnet not working with perl 5.8.5
Hi, I am working on a test framework which uses "Net::Telnet" module to connect to remote machines. This framework started failing after I... -
Telnet from perl
I use this NET::TELNET module to login into a telnet session.. THis is the code #!/usr/bin/perl use CGI; $frm = new CGI; $unix_box =... -
Telnet - How to put delays on output?
Hi! I have a slow device attached to a terminal server reachable by socket. To access it just do "telnet ip-address socket-number". I need to... -
Perl and telnet
Hello, I am trying to get Perl to make the hard things possible, but I'm having my doubts on this one... We basically have a huge C program... -
xemoth@gmail.com #2
Re: getting output of telnet from perl script
Don't have Net::Telnet here, but does it not have a debug option.
Debug=>Filename ??
Check perldoc Net::Telnet
Owen
xemoth@gmail.com Guest
-
kishore.konjeti@gmail.com #3
Re: getting output of telnet from perl script
yes i am getting output of telnet in debug folder by specifiying in
input_log parameter while telnet object construction. It is showing
correctly.. but i am not able to print using print @lines.
the code is i have written like this
use warnings;
use Net::Telnet;
my $dumplog = "dumplog.txt";
my $outputlog = "outputlog.txt";
my $inputlog="inputlog.txt";
# instantiate a new CGI object
my $telnet = new Net::Telnet(Timeout => 10,
Errmode => 'die',
Dump_Log => "$dumplog",
output_log => "$outputlog",
input_log=>"$inputlog",
);
# perform a single print statement, with liberal use of the perl
# string concatenator "." and some CGI methods
$telnet->open("server");
$telnet->waitfor('/login: $/i');
#$telnet->output_record_separator("\n");
$telnet->print("ixlourd") ;
$telnet->waitfor('/password: $/i');
$telnet->print("qwest1") ;
$telnet->waitfor('/ixlourd\@e2epia2: $/') ;
print "Before ls\n";
@lines= $telnet->cmd("banner KISHORE");
sleep(5);
print @lines; # here i am getting timed out error.
kishore.konjeti@gmail.com Guest
-
DJ Stunks #4
Re: getting output of telnet from perl script
[email]kishore.konjeti@gmail.com[/email] wrote:How can you be trying to use a module without reading the> yes i am getting output of telnet in debug folder by specifiying in
> input_log parameter while telnet object construction. It is showing
> correctly.. but i am not able to print using print @lines.
> the code is i have written like this
> use warnings;
> use Net::Telnet;
> my $dumplog = "dumplog.txt";
> my $outputlog = "outputlog.txt";
> my $inputlog="inputlog.txt";
> # instantiate a new CGI object
> my $telnet = new Net::Telnet(Timeout => 10,
> Errmode => 'die',
> Dump_Log => "$dumplog",
> output_log => "$outputlog",
> input_log=>"$inputlog",
>
> );
> # perform a single print statement, with liberal use of the perl
> # string concatenator "." and some CGI methods
>
> $telnet->open("server");
> $telnet->waitfor('/login: $/i');
> #$telnet->output_record_separator("\n");
> $telnet->print("ixlourd") ;
> $telnet->waitfor('/password: $/i');
> $telnet->print("qwest1") ;
>
> $telnet->waitfor('/ixlourd\@e2epia2: $/') ;
>
>
> print "Before ls\n";
>
>
> @lines= $telnet->cmd("banner KISHORE");
> sleep(5);
>
> print @lines; # here i am getting timed out error.
documentation?
if you prompt is really 'ixlourd@e2epia2: ' then the default Prompt
won't work ((care of the documentation I know that The default Prompt
is '/[\$%#>] $/')), so how do you expect cmd() to know when it's done
getting input?? It sits there waiting to see something it recognizes
until it times out.
Here's how I usually approach this kind of problem:
1) read module documentation
2) write script with frequent reference to module documentation and
examples therein
3) run script
4) when (not if) script does not do what I expected, re-read
documentation and debug
You may want to consider a similar approach.
-jp
DJ Stunks Guest
-
kishore.konjeti@gmail.com #5
Re: getting output of telnet from perl script
I have red the document. can u briefly tell this.. that means.. wht r
the changes i have to do in my script..( waitfor is for waiting for a
specified text needs to appear then can i use sleep for a time. may for
2 or 3 sec..) ..insted of cmd will print command can i use for
executing any commands and getting output of it in a variable ... how
can i supress timed out warning..
-kish
kishore.konjeti@gmail.com Guest
-
Jürgen Exner #6
Re: getting output of telnet from perl script
[email]kishore.konjeti@gmail.com[/email] wrote:
What document? Documentation to some module? Which module are your talking> I have red the document.
about?
What do you mean by "u"? I realize that English is not your native language,> can u briefly tell this.. that means.. wht
but please make an effort to write readable text.
What do you mean by "r"? I realize that English is not your native language,> r the changes i have to do in my script..
but please make an effort to write readable text.
What script? I don't see any script in your posting.
Are you asking a question or are you making a statement here? I really don't> ( waitfor is for waiting for
> a specified text needs to appear then can i use sleep for a time.
understand.
You know, newlines are not a scarce resource. Hitting the "enter" key every> may
> for 2 or 3 sec..)
now and then in the right places would improve the readability of your text
significantly. And I assume you want to be read, right?
What the *$#%&$% ? What is that supposed to mean? "Instead of cmd will print> ..insted of cmd will print command can i use for
command can I use".
Sorry, my English parser fails to parse that sentence.
Are you looking for backticks by any chance? See also the documentation of> executing any commands and getting output of it in a variable .
system().
Perl does not generate timeout warnings. Check the documentation of whatever> .. how
> can i supress timed out warning..
tools happens to generate them.
jue
Jürgen Exner Guest



Reply With Quote

