scp output fm script won't go to file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp output fm script won't go to file
# 1  
Old 01-31-2007
scp output fm script won't go to file

Have a script that scp's tar file to multiple other servers in a for loop. Need to set monitoring and notification on it for when it fails.

Running this line of code in a 'for' loop...

scp $SOURCE_RECOVERY_TARFILE ${HOST}:${CURR_RECOV_TARFILE} 2>&1 | tee ${MONFILE}

Their are two outputs from a forced error... a redirect from the executable to a log file for the entire script. Then I'm also trying to monitor each loop for errors so we know where and when the script is failing.

Currently the script log looks like this...

^M^[[3g^M ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H ^[H
^[H ^[H ^[H ^[H ^[H^MCOS dbtool1
logout

My loop error file ( $MONFILE ) is showing up empty while the screen is showing...

./recovery_COS_ASEs.dev[38]: SOURCE__RECOVERY_TARFILE: Parameter not set.
logout

All the methods I've tried for redirecting output to a file isn't working on this HPUX server. Any ideas, I'd be grateful.

Last edited by nmikes; 01-31-2007 at 12:05 PM..
# 2  
Old 01-31-2007
./recovery_COS_ASEs.dev[38]: SOURCE__RECOVERY_TARFILE: Parameter not set.
Perhaps :
Script file is : ./recovery_COS_ASEs.dev
nounset option is selected (ksh, set -o nounset) and variable SOURCE__RECOVERY_TARFILE is not set or define.



Jean-Pierre.
# 3  
Old 01-31-2007
You are correct, this is the error I forced. I'm trying to get that error message to write to a file... for some reason its not reading standard out.
# 4  
Old 01-31-2007
The error message is displayed on stderr by the shell, not by the scp command.
If you want to catch the message you must redirect the stderr of you shell.
First solution:
Code:
./recovery_COS_ASEs.dev 2> errorfile

Second solution, inside the script
Code:
exec 2> errorfile

Jean-Pierre.
# 5  
Old 01-31-2007
its odd,

when the following is run..

scp $SOURCE_RECOVERY_TARFILE ${HOST}:${CURR__RECOV_TARFILE} 2> ${MONFILE}

the monitor file ($MONFILE) is not created... when I run the one below the $MONFILE is created but its empty with the error message "Parameter not set" just showing up on the screen and not getting read to the ${MONFILE}.

scp $SOURCE_RECOVERY_TARFILE ${HOST}:${CURR_RECOV_TARFILE} 2>&1 ${MONFILE}
# 6  
Old 01-31-2007
Why not simply request the return code of the scp command?
It will indicate if the copy succeeded.


for HOST in .........
do


scp .........................
if [ $? -ne 0 ]
then
echo "copy failed to host: $HOST
fi

done
# 7  
Old 01-31-2007
Thanks I really do appreciate it,

I'll give it a shot and let you know... I've gotta work on something else for the rest of the day.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK... (3 Replies)
Discussion started by: yelirt5
3 Replies

2. Shell Programming and Scripting

Need a script to scp a file to multiple boxes

Hello All, I am new to scripting and I am trying to write a script which can scp a file from one box to multiple boxes. I am thinking to do like this. 1) create a file with list of all server names 2)write a script which will pick up each server line by line from server list and copy it to... (1 Reply)
Discussion started by: sintilash
1 Replies

3. UNIX for Dummies Questions & Answers

Unable to copy file using SCP (Input/output & Permission denied error)

Hi, I am facing issue while using scp. Source & target machines are Linux & HP-UX respectively. On target machine, if I fire the following command, I get error: Now if I try scp on another file, which is on the same source machine, it works fine. All directories and subdirectories... (2 Replies)
Discussion started by: Technext
2 Replies

4. Solaris

scp output

Hi, I use an expect script to scp a file from server1. It use to work fine until i tried them on some specific sparc servers where it failed. Upon some analysis i found that the output of scp was different, causing expect to fail. Generally when we do scp a file from server1, we are... (2 Replies)
Discussion started by: Mack1982
2 Replies

5. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

6. UNIX for Advanced & Expert Users

Automated SCP script passing password to preserve source file timestamp

Hi My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file. By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Discussion started by: skumar75
1 Replies

7. Shell Programming and Scripting

Script to SCP a file to multiple servers

Hi All, I am a total noob to the Unix world, and i hope to learn a lot from this wonderful community. Here's my first post and question , i am trying to SCP a file to multiple servers (multiple destinations) through this little script : #!/bin/ksh # copy files # File to be copied... (7 Replies)
Discussion started by: rdlover
7 Replies

8. Shell Programming and Scripting

how to direct scp output to a file in bash shell or script

I can run this from the command line: scp -i identfile /path/file_to_send remotelogin@remotebox:/path_to_put_it/file_to_send and I get: file_to_send 100% |***************************************************************************| 0 00:00 but if I do: scp -i identfile... (6 Replies)
Discussion started by: NewSolarisAdmin
6 Replies

9. Shell Programming and Scripting

Capture scp output

I have a simple script that uses scp to copy some files from one server to another. I want to capture the files that are copied but simple redirection to a file does not work. So I want to capture this output from the scp command in a log file. -bash-3.00$ scp -pr /export/jumpstart/Files... (7 Replies)
Discussion started by: Tornado
7 Replies

10. UNIX for Dummies Questions & Answers

2 ftps in script, second won't go to output file

I'm running this on both solaris and hp boxes, ftping from windows, then ftping to an aix machine. If I run the ftpReportFile by itself, I get info in the ftp_rpt_log. If I run just the 2 ftps together, I also get output. However, if I run the entire shell script, I don't get output from... (4 Replies)
Discussion started by: brdholman
4 Replies
Login or Register to Ask a Question