Hi Jay, Thanks for your resoponse. I tried with the suggested but it failed due to timed out <snip>(j.pl) use Net::Telnet; my $t = new Net::Telnet; $t->open("slias10"); print($t->waitfor('/login:.*$/')); $t->print("root"); sleep(2); @forecast=$t->cmd("/usr/bin/ls"); print @forecast; </snip> <OP> C:\>perl j.pl
HP-UX slias10 B.11.31 U ia64 (ta) command timed-out at j.pl line 7 login: </OP> Please, suggest i am able to see the On 5/16/07, Jay Savage <[EMAIL PROTECTED]> wrote:
On 5/16/07, a b <[EMAIL PROTECTED]> wrote: > Hello, > I am trying to telnet to all m/c for which i haven't set password(only root > is a valid user) > any body can telnet using root user > But when i try to access through perl it > <snip> > use warnings; > use Net::Telnet; > > my $t = new Net::Telnet (Timeout => 10,Prompt => '/bash\$ $/'); > my @line; > $t->open("host1"); > $t->waitfor('/login:.*$/'); > $t->print("root"); > $forecast=$t->print("/usr/bin/ls"); > print $forecast; > > > O/P : 1 > > OR > > use warnings; > use Net::Ping; > use Net::Telnet; > > my $t = new Net::Telnet (Timeout => 10,Prompt => '/bash\$ $/'); > my @line; > $t->open("host1"); > $t->login("root",""); > $result=$t->cmd("/usr/bin/ls"); > print $result; > > O/P : timed-out waiting for password prompt at j.pl line 8 > > Close. You do the login correctly in example 1, but then you use print to issue the command. all that does is print the string "/usr/bin/ls\n" to the remote terminal and return 1 to let you know the command succeeded. If you want the output of the remote command, you need to use cmd (in list context) In example 2, you don't pass a password to login or waitfor one, so you never login. You do, though, use cmd, which is what you want, although you need list context: $t->open("host1"); $t->waitfor('/login:.*$/'); $t->print("root"); my @forecast=$t->cmd("/usr/bin/ls"); my $scalar_forecast = join "", @forecast; # or join'\n', I don't remember if cmd returns newlines or not HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!