Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > First Commercial Perl Program

Reply
Thread Tools

First Commercial Perl Program

 
 
tbb!/fbr!
Guest
Posts: n/a
 
      03-10-2012
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:erl;

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:erl->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
 
Reply With Quote
 
 
 
 
tbb!/fbr!
Guest
Posts: n/a
 
      03-10-2012
On Mar 10, 11:03*am, "tbb!/fbr!" <(E-Mail Removed)> wrote:
> 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:erl;
>
> 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:erl->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


****, wrong newsgroup...

Ron
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
First Commercial Perl Program tbb!/fbr! Perl Misc 30 05-20-2012 06:37 PM
FAQ 2.15 Where can I buy a commercial version of perl? PerlFAQ Server Perl Misc 0 04-23-2011 10:00 PM
Commercial Java program bundled with 'free' database? Korto Java 29 11-15-2006 11:23 AM
Using embedded PERL with commercial applications? Patrick Finnegan Perl Misc 13 11-26-2004 06:54 PM
Perl 'system' Creates Program That Dies When First C Program Dies Christopher M. Lusardi Perl Misc 3 10-19-2003 11:53 AM



Advertisments