Hello Reuben,

Welcome to the list. 

> If I SSH to my webserver and run perl myscript.cgi the script works fine. 

you run it as local user 'yourname'

> If I access http://www.mywebsite.com/myscript.cgi, the
> script produces the results as expected.

most probably it will run as user 'http' (for most hosting companies)

> But when I try to add that command to a cron job to 
> be executed every 5 minuts using Cpanel I get the following error by
> email..
>
> [Thu Jul 14 20:32:00 2005] myscript.cgi: exec() error: No such file or
> directory at /usr/lib/perl5/site_perl/5.8.7/GnuPG/Interface.pm line 322.

> It is strange how an error is generated from a script that I never opened
> (Interface.pm).

it is a script of CPAN module GnuPG::Interface, your cgi script has a line:

use GnuPG::Interface;

Do you have several perl installations? In this case CPAN configured 
diferently for every installation. So that system perl can find GnuPG module, 
an user space perl wont.

not sure which user for cron 'Cpanel' will use, but cron uses restricted PATH

> When I run that command using SSH, before that, I actually login as 'root'.
root usually has different PATH than normal user

PATH effects what copy of program would be run (first found). In shell use 
'which programname' to see which program is executed for current PATH.

> So maybe it is a permissions issue and that's why it is not working as a
> cron job, but I am not excluding any other reasons. How can I login as root
> before running that cron job command?

Cron runs with different permissions for root and user. ssh into server as 
root and use 'crontab -e' command to setup cron jobs. (man crontab)

> If I don't solve this problem, is there another way to call myscript.cgi
> every 5 minutes?  So, as plan B, is there a way to
> call that URL every 5 minutes?

you can use then 'wget http://www.mywebsite.com/myscript.cgi > /dev/null'
Regards,

Gregory Smirnov

Reply via email to