By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

is there a perl mechanism to ping a network element before issuing SNMP commands?

P: 12
Since I found the site by googling, I will post a new question in addition to my follow-on response, with belief it will aid others. And increased crossing of fingers it will aid in receiving a response.

Cutting to the chase.....

i can use a system call to issue a ping to network element easily enough

Ie, system("/directory1/directory2/command like i was in CLI");

how can i harvest the response from the remote element to logically decide the next move?

am i on the right track in thinking you can use the if or else logic with a command line response?


Hutch
Mar 14 '08 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Since I found the site by googling, I will post a new question in addition to my follow-on response, with belief it will aid others. And increased crossing of fingers it will aid in receiving a response.

Cutting to the chase.....

i can use a system call to issue a ping to network element easily enough

Ie, system("/directory1/directory2/command like i was in CLI");

how can i harvest the response from the remote element to logically decide the next move?

am i on the right track in thinking you can use the if or else logic with a command line response?


Hutch
Have you searched CPAN to see what modules are available? You may find one that will work for you.

Regards,

Jeff
Mar 14 '08 #2

P: 12
Thanks Mate, I was trying to steer clear of any modules. The SA won't allow any use of XYZ beyond basic perl functionality. Don't ask my=[me]-edit why. I'm just wearing the development hat as a one-off here.

Just looking for basic perl functionality to do the task at hand.

Cheers,

Hutch
Mar 14 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
Thanks Mate, I was trying to steer clear of any modules. The SA won't allow any use of XYZ beyond basic perl functionality. Don't ask my=[me]-edit why. I'm just wearing the development hat as a one-off here.

Just looking for basic perl functionality to do the task at hand.

Cheers,

Hutch
Well then, you have only a couple of choices.

First, you could just use the system function to ping the remote host:

Expand|Select|Wrap|Line Numbers
  1.  
  2. system("pint remote_host");
  3.  
or, you could download the a module that can do what you are looking for and copy the code out of it directly and use it that way (that way you don't have to install the module).

Choice is yours.

Regards,

Jeff
Mar 14 '08 #4

P: 2
How about:

Expand|Select|Wrap|Line Numbers
  1. use Net::Ping;
  2. $host="myServer";
  3. $p = Net::Ping->new();
  4. if($p->ping($host)){
  5.   print "$host is alive.\n";
  6. }else{
  7.   print "$host is down.\n";
  8. }
  9. $p->close();
Mar 14 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.