Click here to get back home

Net::Telnet - Problems using "script->waitfor" - HELP Needed

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::Telnet - Problems using "script->waitfor" - HELP Needed mark1.thompson45 11-26-2005
Posted by mark1.thompson45 on November 26, 2005, 1:13 am
Please log in for more thread options


Hello All,
I am having problems getting my Perl script to detect
different login scenarios in a unix environment. My code will work OK
for one box but every now and then a box will be configured differently
and the login prompts will be different, catering for this eventuality
in my script is where I am struggling, here is a snippet of the code:-

---------------------------------------------------------------------------------------------------------------------------------------
sub Telnet_To_Device
        {
        $script = new Net::Telnet ( Timeout=>5, Errmode=>'return', Prompt =>
"/:/i");
        $script->dump_log(@Data[0]."debug.log");
        if (!($script->open(@Data[1])))
{
print "FAILED TO CENNECT TO @Data[1]\n";
         return;
        } else {
                $script->waitfor('/login:/i');
                $script->print(@Data[2]);
                $script->waitfor('/password:/i');
                $script->print(@Data[3]);
                $script->waitfor('/Do you understand/i');
                $script->print('Y');
         $script->waitfor('/:/');
                #uname();
                $script->print('quit');
         }
        }

---------------------------------------------------------------------------------------------------------------------------------------

As I said this will work for 80% of my machines but for the other 20%
there is a sticking point at the point just after where I input the
password, for these 20% of boxes they do not prompt the user for "Do
you understand" and expect the user to return either "Y/N" they go
straight to the box shell prompt. How can I get the code to say if you
see this then do this or if you see that then do that, an 'IF'
statement basically, the only way I can see this working is if you have
a list of the boxes that do this and then you can use an IF on the box
names to present different logins, this seems to long winded though,
there must be an easier route.

p.s. I have read the PM file before anyone asks, I could not find the
answer there.

Cheers, Mark.



Similar ThreadsPosted
How do you telnet from 1 host to another using Telnet Module December 21, 2005, 4:15 pm
Net::FTP help needed January 15, 2007, 9:58 pm
Help needed with XML::Smart September 23, 2004, 9:41 am
Help needed with MakeMaker August 15, 2005, 2:37 pm
net::telnet to ms telnet server May 19, 2005, 12:28 am
Audio DSP Info needed October 18, 2004, 11:00 pm
Perl programmer needed June 22, 2006, 2:12 am
fork process help needed March 15, 2007, 8:56 pm
Net::SFTP and Net::SSH::Perl hangs or disconnets. Help needed. October 25, 2004, 2:39 am
Stream filtering Module/Language needed September 24, 2007, 5:34 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap