Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks! I am trying to net telnet to a system and run a command on every disk entry in the file "disks" will this work? thanks!!
#!/usr/bin/perl -w use Net::Telnet @files = disks, readdir(MDIR)); $t = new Net::Telnet(Timeout => 2810, Prompt => '/%/', Host => 'hostname' ); $t->login( "username", "password" ); foreach $x ( @files ) { $t->cmd( "run command here/$x" );

Replies are listed 'Best First'.
Re: net telnet help
by meetraz (Hermit) on Dec 15, 2004 at 22:26 UTC
    Close, but I think this is what you want:

    #!/usr/bin/perl -w use strict; use Net::Telnet; open (INPUT, 'disks') or die $!; my @disks = <INPUT>; close (INPUT); my $conn = new Net::Telnet(Timeout => 2810, Prompt => '/%/', Host => 'hostname' ); $conn->login( "username", "password" ); foreach my $disk ( @disks ) { chomp($disk); $conn->cmd( "run command here $disk" ); }
      Don't forget to chomp(@disks).
Re: net telnet help
by Anonymous Monk on Dec 15, 2004 at 22:30 UTC
    thanks that works like a champ! much appreciated