I usually don't spend time fixing scripts which already work unless there is a compelling reason to do so. If you are using SSH2, a perl version can reduce the number of
ssh calls and thus be a little more efficient. Additionally, a perl version would allow you to refactor the code so that it is more maintainable and perhaps reusable by other programs. For instance, consider replacing code like this:
MODEL=`/opt/adi/bin/adcat.py -x computer $HOST|grep Model|awk '{print
+ $3}'`
with a subroutine like this:
sub get_model {
my $host = shift;
...
}
Even if the initial implementation of this routine is the same as the shell version, by creating this interface you'll be able to change the implementation later. This routine might also be useful in other scripts.
You can attempt the same refactoring with shell functions, but you won't be able to pass around complex data structures which will prove to be limiting. For instance, it is clear that the adcat.py returns a lot of information about a host, and being able to pass that information back as a hash is much more efficient (and natural) than writing separate get routines for each attribute.
If you need help using Net::SSH or Net::SSH::Perl, just let us know.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.