Read on full site | Join TechSpot! (it's free) | Bookmark / Share this



Unix shell script - novice question

jej1216
02-03-2005, 06:46 PM
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}

Post a reply, see related topics & more

Tip: Download Advanced SystemCare 3 Free - Clean, Repair, Protect & Optimize your PC.



 Top Technology News

TechSpot Blog: Disable Windows automatic check for solutions after a program crashes

Weekend Open Forum: Google Chrome OS and the future of cloud computing

Tech Tip of the Week: Unearth Region-Specific Windows 7 Themes

Sony: PlayStation 3 to be 3D-capable via firmware update

iSuppli: DDR3 to account for over half of DRAM shipments by Q2 2010

Facebook named third most popular video website behind YouTube and Hulu

Patriot introduces new PS-100 SSD series

Sony working on digital store for music, movies, books

More Tech News

  
 Software Downloads

Norton Virus Definitions 2003-07 November 20, 2009

AVG Anti-Virus Updates November 20, 2009

Norton Virus Definitions 2008-09 November 20, 2009

avast! Virus Definitions November 20, 2009

McAfee SuperDAT Update 5808

Kaspersky Anti-Virus Update November 20, 2009

Google SketchUp 7.1.6087

More Downloads



Copyright © 1998-2009 TechSpot.com. TechSpot is a registered trademark. All Rights Reserved.