This is what I am trying to do with Perl - my code is down below these instructions - the commented parts are the ones I can't figure out....
nslookup hostname- if it comes with xx.xxx.xxx.110 do nothing. If it comes back with xx.xxx.xxx.110 then; Send mail here...
ping hostname.domain.com - if no reply do nothing. If alive then;
ssh root@xx.xxx.xxx.xxx 3dpipe wideip hostname pool pool_sde_primary virtual show all - look for enabled. If not found then;
ssh root@xx.xxx.xxx.xxx 3dpipe virtual xx.xxx.xxx.110:443 disabled
ssh root@xx.xxx.xxx.xxx 3dpipe virtual xx.xxx.xxx.110:443 disabled
ssh root@xx.xxx.xxx.xxx 3dpipe virtual xx.xxx.xxx.110:443 enable
ssh root@xx.xxx.xxx.xxx 3dpipe virtual xx.xxx.xxx.110:443 enable
3dpipe wideip hostname pool pool_sde_primary virtual show all
ssh root@xx.xxx.xxx.xxx 3dpipe wideip hostname pool pool_sde_primary virtual show all
send mail blah blah
Here is what I have so far....
#!/usr/bin/perl -w
system("nslookup domain domain");
#if returns on 5th line "Address: xxx.xxx.xxx.110" do nothing - if no
+t send mail
system("ping hostname");
# if this returns "alive" then do:
my $ssh = Net::SSH::Perl->new("hostname");
$ssh->cmd("3dpipe virtual xx.xxx.xxx.110:443 disabled");
$ssh->cmd("3dpipe virtual xx.xxx.xxx.110:443 disabled");
$ssh->cmd("3dpipe virtual xx.xxx.xxx.110:443 enable");
$ssh->cmd("3dpipe virtual xx.xxx.xxx.110:443 enable");
$ssh->cmd("3dpipe wideip hostname pool pool_sde_primary virtual show a
+ll");
$ssh->cmd("3dpipe wideip hostname pool pool_sde_primary virtual show a
+ll");
Edit by BazB: obsure IP address missed by OP, retitle from "Net::SSH schtuff...."
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.