Welcome to the TechSpot OpenBoards. Please read the FAQ if you have any questions. Sign up or Login to participate.
|
|||||||
Download Now:
Unix shell script - novice question
|
|
Thread Tools | Search this Thread |
|
#1
|
|||
|
|||
|
Unix shell script - novice question
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Unix shell script - novice question - Reply
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. |
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
||||
|
||||
|
Quote:
chmod u=x {add execute permission for user} chmod a=r { read permission for all....} chown yourname filename {change ownership of filename to yourname} |
|
|
![]() |
| Similar Topics | ||||
| Topic | Replies | Forum | ||
Question about Windows Shell and Environment Variables
|
7 | Windows OS | ||
Displays Error: Windows Script Host, Can not find script file "H:/FS6519.dll.vbs"
|
0 | Virus and Malware Removal | ||
Unix script security
|
1 | The Alternative OS | ||
Using Unix..
|
0 | The Alternative OS | ||
Fun with Unix shell
|
0 | The Alternative OS | ||
| Thread Tools | Search this Thread |
|
|
All times are GMT -4. The time now is 10:43 AM.



Question about Windows Shell and Environment Variables