First Commercial Perl Program

T

tbb!/fbr!

I entered the professional perl programming world by being paid
(that's what I call professional, though the code may be far from) for
a very small perl script. The user basically wanted a config file
which contained as the first line a username, the second line a
password, and the remaining lines to be hotnames.

ex.
user
pass
127.0.0.1
127.0.0.2

Then I wrote the following script. It gathers the user, pass, and
hostlist, and then establishes an ssh connection to query a 'device'
and return the output in a file named after the host. Following is
that program:


#!/usr/bin/perl

# Code by
# For
# dmon-1.6

use warnings;
use strict;
use Net::SSH::perl;

my $cfgfile="./config";
open CONFIG, "<", $cfgfile || die $!;
chomp(my @cfgdat=(<CONFIG>));
my $user=shift(@cfgdat);
my $pass=shift(@cfgdat);
my $extcmd="ls -l";
my $stime=3;

while (defined $stime) {
foreach (@cfgdat) {
my $ssh=Net::SSH::perl->new($_);
$ssh->login($user,$pass);
my ($stdout,$stderr,$exit)=$ssh->cmd($extcmd);
open OUTFILE, ">>", $_ || die $!;
if ($stdout) {
print OUTFILE $stdout;
}
if ($stderr) {
print OUTFILE $stderr;
}
close OUTFILE;
}
sleep $stime;
}

I am just looking for critique. I have been a Unix Admin for over 15
years, and have used perl for one off scripts, but I spent time and
master Oreillys Learning Perl and Intermediate Perl (Mastering and
Advanced Perl are next) and am now looking to solely become a
commercial perl programmer. However, as I lack commercial experience,
I probably lack a 'standard' way of approaching things, or at least
don't know what experienced perl programmers know, which I'll learn as
a function of time. Either way, if you have time, let me know how I
could have done all this better, and maybe even a source of commercial
perl programs I can look at and see how pro's do it.

Ron
 
T

tbb!/fbr!

I entered the professional perl programming world by being paid
(that's what I call professional, though the code may be far from) for
a very small perl script. The user basically wanted a config file
which contained as the first line a username, the second line a
password, and the remaining lines to be hotnames.

ex.
user
pass
127.0.0.1
127.0.0.2

Then I wrote the following script. It gathers the user, pass, and
hostlist, and then establishes an ssh connection to query a 'device'
and return the output in a file named after the host. Following is
that program:

#!/usr/bin/perl

# Code by
# For
# dmon-1.6

use warnings;
use strict;
use Net::SSH::perl;

my $cfgfile="./config";
open CONFIG, "<", $cfgfile || die $!;
chomp(my @cfgdat=(<CONFIG>));
my $user=shift(@cfgdat);
my $pass=shift(@cfgdat);
my $extcmd="ls -l";
my $stime=3;

while (defined $stime) {
  foreach (@cfgdat) {
    my $ssh=Net::SSH::perl->new($_);
    $ssh->login($user,$pass);
    my ($stdout,$stderr,$exit)=$ssh->cmd($extcmd);
    open OUTFILE, ">>", $_ || die $!;
    if ($stdout) {
      print OUTFILE $stdout;
    }
    if ($stderr) {
      print OUTFILE $stderr;
    }
    close OUTFILE;
  }
  sleep $stime;

}

I am just looking for critique. I have been a Unix Admin for over 15
years, and have used perl for one off scripts, but I spent time and
master Oreillys Learning Perl and Intermediate Perl (Mastering and
Advanced Perl are next) and am now looking to solely become a
commercial perl programmer. However, as I lack commercial experience,
I probably lack a 'standard' way of approaching things, or at least
don't know what experienced perl programmers know, which I'll learn as
a function of time. Either way, if you have time, let me know how I
could have done all this better, and maybe even a source of commercial
perl programs I can look at and see how pro's do it.

Ron

shit, wrong newsgroup...

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top