On Jul 14, 7:16 am, [email protected] (Sooraj S) wrote:
>  Hi I am very new to perl. I want to login to a remote machine and
> check a directory exists or not.
>
> my code:
> ========
>
> using Net::Telnet;
>
> $t = new Net::Telnet();
> $t->open($remote_system);
> $t->login($username, $passwd);
>
> # this doesnot work.
> if (-d $my_dir) { print "ready to go"; }
>
> $t->close();

See the 'cmd' method in Net::Telnet docs: perldoc Net::Telnet.
Net::Telnet can still useful in changing passwords for instance
but only over ssh. Net::Telnet even provides a passwd change
example over ssh.

But, again, you should definitely be using ssh.  There are other
modules which can facilitate this such as Net::SSH2,  the earlier
mentioned Net::SSH::Expect, and Net::SSH::Perl.  Check CPAN.

Warning:: Net::SSH::Perl isn't that easy to build IMO. (Or at least
that used to be the case.) You might want to stick to Net::SSH2.

--
Charles DeRykus


--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to