Operating System - Linux
1753452 Members
5865 Online
108794 Solutions
New Discussion юеВ

Re: Crontab and Connect Direct Compatability

 
SOLVED
Go to solution
surekha_4
Occasional Advisor

Crontab and Connect Direct Compatability

I am trying to get the status of all the files uploaded through connect direct using
a shell script.

the Connect direct utility for the same lies in /opt/cdunix/ndm/bin/ directory.

When i try running the shell script from crontab i get the following error
"Failed to read configuration file, exiting".

But i am able to run the same from from any other directory.
10 REPLIES 10
Josef Forman
Frequent Advisor

Re: Crontab and Connect Direct Compatability

Hi,
I think you have the same problem, like I had.
When you run your script from command line, you have some enviroment (command env), but when you run from contab, there is not the same enviroment. Expecially you need PATH maybe other variables.
Try what you need, what you have in your profile, it is not used in environment during running in crontab.

PF
surekha_4
Occasional Advisor

Re: Crontab and Connect Direct Compatability

Yeah.. the path, is not being read properly.
I have hardcoded the path in the script.

But the problem is crontab works from /bin/ksh directory and connect direct from /opt/cdunix/ndm/bin/ directory.

Is there any way i can run this script from crontab?
Josef Forman
Frequent Advisor

Re: Crontab and Connect Direct Compatability

Hi,

first - you can initiate variables by adding line to crontab
(example...
for my oracle crontab at the begining I add
PATH="/u01/app/oracle/product/10.1.0/db_1/bin")

second - you can use in the script at first line !#/bin/ksh

third - it looks like the script cannot find conf. file where it is placed?

PF
surekha_4
Occasional Advisor

Re: Crontab and Connect Direct Compatability

Hi,

My crontab entry is this:

45 00 * * * SVC_HOME=${HOME} ${HOME}/scripts/ConDirRep.pl

From within ConDirRep.pl i am calling a shell script which
gets me the Connect Direct status.

Yes, i have included !#/bin/ksh in the shell script
and #!/usr/bin/perl in the perl script.

Both the shell, as well as the perl scripts are in /app/sur/scripts directory.

$HOME = /app/sur/

Regards,
Surekha
Josef Forman
Frequent Advisor

Re: Crontab and Connect Direct Compatability

Hi,
did you solve your problem?
Sorry, but on the Friday I had to go home.

I think everything is OK, but the config ("Failed to read configuration file, exiting".) is on different place then you run your scripts. You should change your pwd to place, where you have your config file or in your script use absolute path to your config file.

PF
Muthukumar_5
Honored Contributor

Re: Crontab and Connect Direct Compatability

Can you able to execute the two scripts on command line? Check the permission of those 2 files so that it is having executable permission.

45 00 * * * SVC_HOME=${HOME} ${HOME}/scripts/ConDirRep.pl

If you want to set environment variable then, try it before configuration line as,

SVC_HOME=${HOME}
45 00 * * * sur ${HOME}/scripts/ConDirRep.pl

where sur is your username.

${HOME} , userinformations are being retrieved from /etc/passwd file. Are you trying from your user.?

If you try it from other users or root then it will try it from their home directory.

Regards
Muthu
Easy to suggest when don't know about the problem!
surekha_4
Occasional Advisor

Re: Crontab and Connect Direct Compatability

Yes, i can execute the script on command line.
Permissions are 755.
User also has permissions set.

Can you tell me which all directories crontab has access?

Because the directory i am trying to read from is
/opt/cdunix/ndm
Jeroen Peereboom
Honored Contributor
Solution

Re: Crontab and Connect Direct Compatability

L.S.

Your crontab entry

45 00 * * * SVC_HOME=${HOME} ${HOME}/scripts/ConDirRep.pl

should be like:
45 00 * * * SVC_HOME=${HOME}; export SVC_HOME; ${HOME}/scripts/ConDirRep.pl

This way SVC_HOME will be exported to the sub processes.

A better way is to write a wrapper around your perl script, that sets all variables.
Maybe even better is to have 1 file containing all variable settings and sourcing this file from a shell script (. .../filename) or perl script (....).

JP.

Did you read http://forums1.itrc.hp.com/service/forums/helptips.do?#28
surekha_4
Occasional Advisor

Re: Crontab and Connect Direct Compatability

Hi All,

I wrote a wrapper as suggested... and It worked. I set all the required environment parameters out there.

Thanks a lot for you help.

Regards,
Surekha