Log file problem

I want to transfer files from ABC server to XYZ server in which i am successful. I would like to create a log file also by the name of current date. For some reason my script gives me an error on my scp -p command and it says LOCAL_LOG_FILE: not found and REMOTE_LOG_FILE not found. Any clues whats going on?

LOCAL_LOG_FILE ="log_`date +%m%d%y`"
REMOTE_LOG_FILE ="XYZ:/terry/dukes/bkup/${LOCAL_LOG_FILE}"
date +"%m/%d/%y %H:%M:%S" > $LOCAL_LOG_FILE
scp -p /some/user/files/*.gif
XYZ:/terry/dukes/bkup >$LOCAL_LOG_FILE 2>&1
echo "File copied Successfully `date +%m%d%y:%H:%M:%S`"  >$LOCAL_LOG_FILE
scp -p $LOCAL_LOG_FILE $REMOTE_LOG_FILE

I want to create a log file on the remote system + local system with the "file copied successfully" message included in that log file. But its not creating a log file. Everytime i run the script i get:

LOCAL_LOG_FILE ="log_`date +%m%d%Y`"
category_captains.sh[32]: LOCAL_LOG_FILE:  not found.
REMOTE_LOG_FILE ="XYZ:/terry/dukes/bkup/${LOCAL_LOG_FILE}"
category_captains.sh[33]: REMOTE_LOG_FILE:  not found.

Because of that i believe its not creating the file

You may have more code than what you posted that is blowing away the file. I am thinking this is so since the code you posted, you are overwritting what you wanted in there:


LOCAL_LOG_FILE ="log_`date +%m%d%y`"
REMOTE_LOG_FILE ="XYZ:/terry/dukes/bkup/${LOCAL_LOG_FILE}"
# Next line creates new file due to > character
date +"%m/%d/%y %H:%M:%S" > $LOCAL_LOG_FILE
scp -p /some/user/files/*.gif
XYZ:/terry/dukes/bkup >$LOCAL_LOG_FILE 2>&1
# This line overwrites what you put in the file already due to > character #   you want to append so use >>
echo "File copied Successfully `date +%m%d%y:%H:%M:%S`"  >$LOCAL_LOG_FILE
scp -p $LOCAL_LOG_FILE $REMOTE_LOG_FILE

That's all the code i am using. Secondly the script was working fine until i accidentally removed. I am glad i had the print out in front of me. So i am typing exactly the same thing but everytime i run my script it gives me that LOCAL_LOG_FILE not found and REMOTE_LOG_FILE not found.

I have been trying to debug but dont know whats going on. I had my chmod 777 (filename).

Post how you are running the script and the output of echo $SHELL from the command line, please.

Hmm,

got the soln.

what you have done is
LOCAL_LOG_FILE<space>="log_`date +%m%d%Y`"
category_captains.sh[32]: LOCAL_LOG_FILE: not found.
REMOTE_LOG_FILE ="XYZ:/terry/dukes/bkup/${LOCAL_LOG_FILE}"
category_captains.sh[33]: REMOTE_LOG_FILE: not found

you should not leave space in between .
eg
[SIVA ~]$ LOCAL_LOG_FILE="log_`date +%m%d%y`"
[SIVA ~]$ echo $LOCAL_LOG_FILE
log_122807

:b: Wishes,
Siva.

Great catch, Sivaswami.

You guys got it man. It was that stupid space. Duh.. I cannot believe i made that mistake.

Say for instance i would like to create a log file only in the remote machine rather than my local machine. What do you think i should do?

Are you planning to create remote log for scp ?

Create a NFS mount on the remote machine that is exported, granting read/write access to it from the local machine.
Then from the local machine have your script write the logfile to the remote mount.

Hope I got that right :wink:

Cheers,
Cameron