TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10172] Perl newbie - starting a telnet process...



I've never tried the Net::Telnet module but I have tried piping to
external processes and had trouble getting a stable implementation.
Here's a bit from the readme:

        use Net::Telnet ();
        $t = new Net::Telnet (Timeout => 10,
                              Prompt => '/bash\$ $/');
        $t->open("sparky");
        $t->login($username, $passwd);
        @lines = $t->cmd("/usr/bin/who");
        print @lines;

Is that easy or what?
Good luck,
Jeff


Mike Glaser wrote:
> 
> I was trying to write a Perl script today that would telnet into a
> router, issue a few commands and then close. I wasn't having any
> luck. Can anyone tell me how to go about doing it?? Here are the
> particulars...
> 
> 1) telnet
> 2) open xxx.xxx.xxx.xxx
> 3) enter_password
> 4) command
> 5) exit
> 
> Here is what my script was looking like...
> 
> #!/usr/bin/perl
> open( TELNETPROC, "|telnet");
> print TELNETPROC "open 192.168.0.1\n";
> print TELNETPROC "thesecretpassword\n";
> print TELNETPROC "clear line 1\n";
> print TELNETPROC "exit\n";
> close FTPPROC;
> 
> What may I be missing here?? I have the O'Reilly book 'Learing Perl'
> to help me get started with Perl, but I have not been able to pick up
> much yet.
> 
> Thanks,
> Mike Glaser
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org