#!/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
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
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
#!/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?
#!/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