"Silverfox" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> hey anyone know how to check if a file exists using the Telnet module?


Net::Telnet allows you to make a TCP connection to a (remote) system.
You should execute a remote command and check the given output to see
if the file exists... Net::Telnet does not provide a built-in function for
that.

example, use the "ls" command to check if a file exists:
-------------------------------
use Net::Telnet ();

my $username = "user";
my $passwd = "password";

$t = new Net::Telnet (Timeout => 10,
                      Prompt => '/\bash\$ $/');
$t->open("localhost");
$t->login($username, $passwd);
@lines = $t->cmd("ls file-to-check.txt");

$lines[0] =~ /No such file or directory/ || print "File exists\n";
-------------------------------

Cheers,

- JeeWee



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to