Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with cron script

Status
Not open for further replies.

pichi

Programmer
Nov 12, 2000
156
EC
hi everybody, i'm running a script in solaris 8, the script is running background, from the cron, it is a perl script, which calls the system("") function, my problem is when use this function with programs compiled in the SO, it didn't work, for example, "ssh", i use it for write "echo" in other server with a ssh connection, but it didn't connect to the server
system("ssh IPaddres \"echo '$user' >> /dir/allusers\"");
, but if i use
system("echo '$user' >> /dir/allusers") it worked!!!,
i don't know if i need to put some SHELL or PATH variables in the script. If i execute the script manually it works!!!, so only with the cron is the problem, hope somebody can help me!! thanks in advance!!!

Pichi
 
Hi Pichi. I'd agree with your diagnosis that you need to ensure that whatever $PATH variable exists when you run the script interactively also needs to be specified in your script, or in a 'wrapper' which will kick off your script from cron. This could be as simple as placing an export PATH=<path required> at the start of your script so that it's set when it comes to the 'action' parts of the script. Hope this helps.
 
Alternatively you could just use the full path to ssh, e.g. :

[tt]system("/usr/local/bin/ssh IPaddres \"echo '$user' >> /dir/allusers\"");[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top