0

I have a cron job that runs several shell scripts:

30 1 * * 1-5 /ufs/00/home/usr/bin/ConsentforFoo.sh "prd"
15 1 * * 1-5 /ufs/00/home/usr/bin/apptTvoxforFoo.sh

the first shell script looks like this:

 #!/bin/bash
 # ConsentforFoo.sh - set different environments, set path to perl scripts, calls      script

TMP_HOME=/home/localweb/htdocs/cgi-bin/usr/CFoodir

if [ "$1" = "dev" ] || [ "$1" = "uat" ] || [ "$1" = "prd" ]
then
cd $TMP_HOME/$1
My-Consent-Cron.pl
else
echo "Val Not Set: $1"
fi

this script works flawlessly... However, the second shell script looks like this:

 #!/bin/bash
 # apptTvoxforFoo.sh - sends MHT population and patients with multiple appointments to west

 TMP_HOME=/home/localweb/htdocs/cgi-bin/usr/CFoodir
cd $TMP_HOME
TvoxCron.pl #adding './' works here

but when it runs, I get an error saying: "sh: /ufs/00/home/usr/bin/apptTvoxforFoo.sh: cannot execute"

I add a "pwd" to the shell script and it's getting in the right directory and the file is there...

Weirdest thing is when I add "./" to it, it works... but in the first shell script I don't have to...

Any ideas why taking the if/then/else out would force me to SOURCE the perl script?

Thanks for any help you can provide.

3
  • 1
    What does ls -l /ufs/00/home/usr/bin/ConsentforFoo.sh /ufs/00/home/usr/bin/apptTvoxforFoo.sh return? Do both perl script have a correct shebang? #!/usr/bin/perl Commented May 13, 2014 at 13:33
  • ./script.pl is not "sourcing" the script, it's just calling it from a relative path. Commented May 13, 2014 at 13:43
  • I think this was prob the issue... this sh script was set for "-rw-r--r--" vs "-rwxr-xr-x" for the one that is working... I have a feeling this will fix the problem. Rookie mistake. Thanks! Commented May 13, 2014 at 13:46

1 Answer 1

1

Did you check the file permissions on the directories and all the files? Can you add a dot in front of the file to make sure you are not finding the file on the path?

./TvoxCron.pl
Sign up to request clarification or add additional context in comments.

2 Comments

hmmm i see your question is why the period is needed... maybe the script in the first case is in your path?
"Cannot execute" is always due to the lack of execute permission.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.