Hi Gang,
Running a script in AIX 5.3. Users wanted me to add a "confirm you want to run script, enter 'y' or 'n'" kind of thing... here is what I came up with:
#!/bin/sh
myfile=`basename "$1"`
dateNow=`date "+%m.%d.%Y.%H.%M.%S"` # Get current date
mydatedfile=$myfile.$dateNow
appfolder="/home/43168134/prod"
newfolder="/home/43168134/arch"
echo "Are you sure you want to approve $myfile ?"
echo ""
echo "Okay?("Y" or "N")=> "
set ret = "$<"
if ("$ret" != "y" && "$ret" != "Y") then
echo ""
echo ""
echo "End."
exit 0
else
if [ -s "$myfile" ]; then
mv "$myfile" "$appfolder/$myfile" # Move file to another folder
cp -p "$appfolder/$myfile" "$newfolder/$mydatedfile" # Copy file with new archive name
print "$myfile has been moved to Production and Archived."
else
print "$myfile does not exist or is empty."
exit 1
fi
fi
exit 0
When I run the script, I get this:
$ approveTEST.sh CallidusFile3.csv
Are you sure you want to approve CallidusFile3.csv ?
Okay?(Y or N)=>
approveTEST.sh[13]: : 0403-006 Execute permission denied.
CallidusFile3.csv has been moved to Production and Archived.
The script does the move/copy OK, but won't accept any input and instead gives me an error. I did chmod 755 and 744 hoping that would fix it, but no luck.
Any thoughts?
Thanks in advance...