Question

Locked

The simple ping command

By billsommerville ·
Hi all,

Got a situation that seems funny to me. I wrote a simple perl script
that performs a ping command to a certain address (This is on a
IMAC).

See below

# Varible definitions
$monivest_ipaddress = "192.168.32.111";
$monivest_ipresults = "monivestip.txt";
#
#-----------------------------------------------------
system "ping -c 15 $monivest_ipaddress > $monivest_ipresults";
END;

***************************

When I use the full path to run the script it works fine. When I use the
./ and the file name it works fine. Now when I put it in cron I get the
following message.

sh: ping: command not found

Can someone tell me what is going on and how I may fix it.

Thanks
Bill

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

forking new shell

by SYNner In reply to The simple ping command

I would venture to guess that you are forking a new shell and that new shell didn't source the profile and you don't have any paths in your environment. For that reason, the full path of the system command is always included in scripts that I see.

Just a guess, not a *nix person.

Collapse -

Sounds right

by deity_chooch In reply to forking new shell

I think when you execute the Perl script from the shell you have those environment variables set and that allows the Perl script to find the ping command in the correct path. I am a Linux person, but can't say I've run into this issue (maybe because I make bash scripts instead of using Perl). Anyway, I think you've got it right and that using the absolute path in the Perl script will fix this.

Collapse -

Thanks for the reply

by billsommerville In reply to Sounds right

Your commends were very helpful. Please see my comment
to SYNner.

Thanks Again.

Collapse -

Thanks for the Info

by billsommerville In reply to forking new shell

It all seemed to be a permissions problem. I did not know
how to fix the cron profile to have the access to the sbin
folder. I kind of thought there may be a security issue there
that I will need more research later. So the quick way to get
it to work was to copy the ping command to the bin folder.
After that everything else was fine. Thanks for the
direction***.

Back to Software Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums