Don't know if this is the right forum for this question, but here goes........
I am just beginning to have to write shell scripts to run SQR processes in UNIX.
I have a script that is having problems copying a file. My code snippet is:
#copy output file out_file1
if [[ -s $out_file1 ]]
then
cp $out_file1 /cde/datasnd/CLIENT/$pg_name2.csv
chmod 666 /cde/datasnd/CLIENT/$pg_name2.csv
file_date=`date +'%Y%m%d.%H.%M.%S'`
arc_file=$ARC_LOC/$pg_name.$FILE_DB.$file_date.dta
cp $out_file1 $arc_file
# Payroll Automation project - copy outbound files to Payroll directories
$SH_LOC/pr_filecopy.sh O D $arc_file NORUNID
gzip $arc_file
chmod 666 $arc_file.gz
# comment out - mv $out_file1 $DATA_LOC/$pg_name2.csv
else
MSG="Process Notice - Output file $out_file1 does not exist"
SUBJ="Process Notice - $FILE_DB - Output file not found"
echo $MSG
# send_message $RECIPIENTS "$MSG" "$SUBJ"
fi
The error messages I get are:
+ [[ -s /opt/PROD/CLIENT/DATA/group.recog_bw.csv ]]
+ cp /opt/PROD/CLIENT/DATA/group.recog_bw.csv /cde/datasnd/CLIENT/group.recog_bw.csv
cp: cannot create /cde/datasnd/CLIENT/group.recog_bw.csv: No such file or directory
+ chmod 666 /cde/datasnd/CLIENT/group.recog_bw.csv
chmod: WARNING: can't access /cde/datasnd/CLIENT/group.recog_bw.csv
I have checked the folder /cde/datasnd/CLIENT/ and it exists.
I have looked at the /opt/PROD/CLIENT/DATA/group.recog_bw.csv and it is there and has 777 rights.
I can manually upload the file into the /cde/datasnd/CLIENT/ with no problems.
There has to be a script error, but I don't see it.
Any Unix shell gurus out there?
Thanks,
jej
Nodsu
02-04-2005, 03:38 AM
Do you have read or execute permissions to all of the directories in the path in question?
You need r or x permissions for cde, datasnd and CLIENT to be able to create that file.
How do you upload the file manually? Your script may be running under different credentials.
Ad
02-04-2005, 03:38 AM
jej1216
02-04-2005, 09:17 AM
I'll check my permissions on cde, datasnd and CLIENT folders. Is there a way I can set those myself?
I've written a few scripts that do a similar function, and the code looks the same to me.
I manuall moved the file by right clicking on the file created in /opt/PROD/CLIENT/DATA/ and downloading it locally, then right clicking on the local copy and uploading it to /cde/datasnd/CLIENT/ using SHH FTP application.
Mictlantecuhtli
02-04-2005, 10:14 AM
if [[ -s $out_file1 ]]
Why are you using double brackets?
Phantasm66
02-04-2005, 11:07 AM
I'll check my permissions on cde, datasnd and CLIENT folders. Is there a way I can set those myself?
chmod a=rwx {all permissions to all users...}
chmod u=x {add execute permission for user}
chmod a=r { read permission for all....}
chown yourname filename
{change ownership of filename to yourname}