Problems coping a file in a shl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems coping a file in a shl script
# 1  
Old 03-23-2011
Problems coping a file in a shl script

I have the following in a shl script:
Code:
SCRIPT_PATH="/u01/app/banner/test/skid/plus/";
FILE_PATH="/nfs/mercury/u03/banner/test/skid/log";
LIST_FILE_PATH="/u01/banjobs/TEST";
SCRIPT_NAME="szpcal1.sql";
FILE_NAME='new_applicant_list';

I want to copy the file FILE_NAME to LIST_FILE_PATH
Code:
cd ${FILE_PATH}
echo 'cp ${FILE_NAME} ${LIS_FILE_PATH} ${LIS_FILE_NAME}' >/u01/scott/scott.txt
cp ${FILE_NAME} ${LIS_FILE_PATH} ${LIS_FILE_NAME}

I know I have all the permissions I need.. I am getting the following error:
Code:
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.05
Successfully executed the szpcal1.sql script
/u01/app/banner/test/links/szpcal1: [[: not found
cp: cannot create szpcal1_saisusr_79847.lis: Permission denied

It is sending the file to >/u01/scott/ (I put this to test)
like ${FILE_NAME} ${LIS_FILE_PATH} ${LIS_FILE_NAME}
it should be szpcal1_saisusr_79847.lis with the data of FILE_NAME

Last edited by Franklin52; 03-24-2011 at 04:10 AM.. Reason: Fixed code tags
# 2  
Old 03-23-2011
Things in single-quotes aren't expanded. Try double quotes " "
# 3  
Old 03-23-2011
Your variable names are LIST_FILE_PATH and LIST_FILE_NAME not LIS_FILE_PATH and LIS_FILE_NAME

Also you don't want a space between the path and name vars on the cp line:

Code:
cp ${FILE_NAME} ${LIST_FILE_PATH}${LIST_FILE_NAME}

# 4  
Old 03-23-2011
Code:
SCRIPT_PATH="/u01/app/banner/test/skid/plus/";
FILE_PATH="/nfs/mercury/u03/banner/test/skid/log";
LIST_FILE_PATH="/u01/banjobs/TEST";
SCRIPT_NAME="szpcal1.sql";
FILE_NAME='new_applicant_list';

cd ${FILE_PATH}
echo 'cp ${FILE_NAME} ${LIST_FILE_PATH}${FILE_NAME}' > /u01/scott/scott.txt
cp ${FILE_PATH}${FILE_NAME} ${LIST_FILE_PATH}${FILE_NAME} -> (previously: ${LIST_FILE_NAME})

# 5  
Old 03-23-2011
After making the corrections to the variable names as suggested above, please re-test and then post the complete script in code tags (including the SQL bit) because there is no way that the error message containing "[[" came from the script posted in post #1.

Also, please stop putting semi-colons at end of Shell command lines. This is unix Shell not SQL.

Most of the typing errors in your script have been addressed. Just to make clear another poster's point:
Quote:
echo 'cp ${FILE_NAME} ${LIST_FILE_PATH}${FILE_NAME}' > /u01/scott/scott.txt
Should be using double quotes not single quotes. Within single quotes the $ variables are not expanded, within double quotes the $ variables are expanded. Also the variable name ${FILE_NAME} appears to be correct in the "echo" statement but incorrect in the actual "cp" statement.
Code:
echo "cp ${FILE_NAME} ${LIST_FILE_PATH}/${FILE_NAME}" > /u01/scott/scott.txt


Quote:
cp ${FILE_NAME} ${LIS_FILE_PATH} ${LIS_FILE_NAME}
In additon to the typing errors in the names of the variables, your "cp" line is missing a solidus.
Also the variable ${LIS_FILE_NAME} should probably be ${FILE_NAME}. Hard to tell for definite without seeing the whole script.
Code:
cp ${FILE_NAME} ${LIST_FILE_PATH}/${FILE_NAME}

The /CODE tag terminator is missing from your CODE tags in your post.

Last edited by methyl; 03-23-2011 at 10:47 PM..
# 6  
Old 03-23-2011
Did you mean code tags look like this:
[code]lines of code[/code]
# 7  
Old 03-23-2011
Code:
SCRIPT_PATH="/u01/app/banner/test/skid/plus/"
FILE_PATH="/nfs/mercury/u03/banner/test/skid/log/"
LIST_FILE_PATH="/u01/banjobs/TEST/"
SCRIPT_NAME="szpcal1.sql"
FILE_NAME="new_applicant_list"

FILE_NAME=`find ${FILE_PATH}${FILE_NAME}*`
echo "cp ${FILE_NAME} ${LIST_FILE_PATH}${FILE_NAME}" > /u01/scott/scott.txt
cp ${FILE_NAME} ${LIST_FILE_PATH}${FILE_NAME}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ftp bash script appends to file using cron instead of coping new file

I have a bash script that is running a mysql query and creating a csv file with a time stamp. It then uploads that to a ftp server. Everything works great when I manually run it. But then I have a cron job set to run every monday, wednesday and friday at 5am est. When the cron job runs, it... (7 Replies)
Discussion started by: akallenberger
7 Replies

2. Shell Programming and Scripting

Need to decrypt a file in a directory (SHL script)

I need to decrypt a file in a directory, I need to write a shl scrip & cron job How I find the files in the directory: the file is like this: dailypayments_sfs_payment_201011151800.dat -d The decrypt command: gpg -o dailypayments_sfs_payment_201011151800.dat -d 20101115 (the date... (7 Replies)
Discussion started by: rechever
7 Replies

3. Shell Programming and Scripting

gzip and encrypted in a shl script

After I move the file to a directory, I need to gzip and encrypted. I never do this in a shl script, I do it from the command line and it works.. cd /home/nelnet spinel:/home/nelnet$ gpg -e 2010_11_07_05_11_xxxxxx_bills.dat.gz `/home/nelnet/.gnupg/gpg.conf' `/home/nelnet/.gnupg/gpg.conf'... (3 Replies)
Discussion started by: rechever
3 Replies

4. Shell Programming and Scripting

last file in a directory in a shl script

I want to capture a last file in a directory in a shl scrip Cd to the directory $last ls -1 *the_bills.dat* | tail -1 This is not problem, but I need to copy that file to another directory, but in order to be able to copy to that directory, I need to su in unix, I am sure my sistem... (2 Replies)
Discussion started by: rechever
2 Replies

5. Shell Programming and Scripting

This code works in the command line but not in a shl script

When I run this code from the command line works spinel.middlebury.edu:/u02/sct/banner/bandev2/middlebury/shl:DEV2$ ls ef* eftseq.dat spinel.middlebury.edu:/u02/sct/banner/bandev2/middlebury/shl:DEV2$ file_seq=$( < eftseq.dat) ... (1 Reply)
Discussion started by: rechever
1 Replies

6. Shell Programming and Scripting

Renaming a file use another file as a sequence calling a shl

have this shl that will FTP a file from the a directory in windows to UNIX, It get the name of the file stored in this variable $UpLoadFileName then put in the local directory LocalDir="${MPATH}/xxxxx/dat_files" that part seems to be working, but then I need to take that file and rename, I am using... (3 Replies)
Discussion started by: rechever
3 Replies

7. Shell Programming and Scripting

Reading a file (one record) in a SHL script

I am trying to read a file in a shl script (only one record) and stored in a variable file_number I got the following read -u $BANNER_HOME/xxxxxxx/misc/EFTSQL.dat file_number file_number2 = $file_number + 1 echo $file_number2 > $BANNER_HOME/xxxxxx/misc/EFTSQL.dat EOF It is not working... (2 Replies)
Discussion started by: rechever
2 Replies

8. Shell Programming and Scripting

Progress bar while coping a file needed.

Hi guys I want to create a script which will show the amount of data that is been copied from one location to another location. For example: Say i have a file called abc.img which is approximately 4 gb of size therfore everytime i copy the file from one location to another i want a progress bar... (3 Replies)
Discussion started by: pinga123
3 Replies

9. Shell Programming and Scripting

shl script capture a file

need to be able to capture a file with the following conditions: The filenames are, for example, 3526_332840.dat, where 3526 is constant, and 332840 is a sequential number which is always a couple hundred greater than the previous day's file. I want to be able to change this script to acoomplish... (1 Reply)
Discussion started by: rechever
1 Replies

10. UNIX for Dummies Questions & Answers

Having problems copying a file from a script

Hello. Complete newbie over here, and I'm hoping you can help me out with this problem. The script copies a file to a directory within my home dir. Permissions are ok and the source file exists. If I execute the cp command from the command line or hardcode the path/file name, it works. ... (6 Replies)
Discussion started by: verdugan
6 Replies
Login or Register to Ask a Question