Bash Script error?

I'm currently playing with the below script;

#!/bin/sh
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
do
     $d
     RC=$?
     if test "$RC" != "0"
     then
          echo "Do you wish to continue? [y]/n"
     read N
     case "$N" in
        Y* | y* )
              ;;
        * )
              exit $RC
              ;;
      esac
fi
done

Once it has processed /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh the below error appears;

-bash-3.00$ ./DB_gen.sh
./DB_gen.sh: /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh: cannot execute
Do you wish to continue? [y]/n

All the scripts look like this;

#!/bin/sh
cat <<EOD_CAT > second_gen_file
Actim Test Script
Second Generated File
EOD_CAT

Obviously changing for First, Third and Fourth.

Can anyone advise?

Cheers
Jamie

Do you have the execute permission to run '/export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh' ?

You haven't execute permission on the file.
Two solutions :
1) Modify permissions of the file :
chmod +rx /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh

2) Modify script :

do
     /bin/sh $d
     RC=$?

Jean-Pierre.

No, however I have just amended the current chmod variables and it's working fine now!

Cheers
Jamie

Forgive me if this sounds daft, as I have said I'm still a newbie!

What does modifying the script the below do?

do
     /bin/sh $d
     RC=$?

Also some of the scripts which are being run within this script are require a date stamp. Manually these would be run as;

./first-file.sh 04/10/2007

However when running the script I would need to replicate this. How could I make the script ask for user input for the date? So the script automatically adds the date (which the user inputs) onto the end of the above line

Cheers
Jamie

#!/bin/sh
#
# User Input Date
#
if [ $1  ]
then
 
    echo using date provided $1
    ENDDATE="$1"
 
else
 
    d=`date +%d`
    m=`date +%m`
    y=`date +%Y`
 
    echo no date provided, defaulting to today $d/$m/$y
    ENDDATE="$d/$m/$y"
 
fi
#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
#
# Error Fail Safe
#
do
     /bin/sh $d
     RC=$?
     if test "$RC" != "0"
     then
          echo "Do you wish to continue? [y]/n"
     read N
     case "$N" in
        Y* | y* )
              ;;
        * )
              exit $RC
              ;;
      esac
fi
done

How does this look? How can I tell the script to run the date at the end of specific sub-scripts?

ENDDATE=`date +%d/%m/%Y`

Like so?

    echo no date provided, defaulting to today $d/$m/$y
    ENDDATE=`date +%d/%m/%Y`

that's right

Thanks for the reply. Can you tell me how I can apply the date to the end of specific scripts within this one?

E.G I need first-file.sh and thrid-file.sh to run as

./first-file.sh 04/10/2007
./third-file.sh 04/10/2007

But within the new script

Thanks again
Jamie

#!/bin/sh
    ENDDATE=date +%d/%m/%Y`
 
fi
#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
do
    .....................
    .....................
    .....................
    "${d}" "${ENDDATE}"
    .....................
    .....................
    .....................

done

Thanks vgersh! Will this not effect all of the scripts?

It the other scripts ignore the command line arguments then all will be well, if not you can use a case statement

case `basename $d` in
    first-file.sh | third-file.sh )
             "${d}" "${ENDDATE}"
             ;;
    * )
             "${d}"
            ;;
esac

Looking something a little bit like;

#
# Begin Scripts
#
for d in  /export/home/siward/staff/pasit/jamiecr/scripts/first-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/second-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/third-file.sh \
             /export/home/siward/staff/pasit/jamiecr/scripts/fourth-file.sh
#
# Date dependant scripts
#
case `basename $d` in
    first-file.sh | thrid-file.sh )
             "${d}" "${ENDDATE}"
             ;;
    * )
             "${d}"
            ;;
esac
#
# Error Fail Safe
#

Thanks for your help guys, appreciated!