Question on SCP and Mail command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question on SCP and Mail command
# 8  
Old 01-18-2008
True i agree

Last edited by chris1234; 02-24-2009 at 12:59 AM..
# 9  
Old 01-18-2008
see if this what you are looking for

Quote:
Originally Posted by chris1234
well if an error occurs on any of the scp i dont want my file successfull command to run and create a log file. That is what i was trying to say so thought to write an if statement and it only executes if the other 2 if statements pass.
Lets use a flags scp1 and scp2

scp1=0
scp2=0

LOCAL_LOG_FILE="category_`date +%m%d%Y`.log"
date +"%m/%d/%Y %H:%M:%S" >$LOCAL_LOG_FILE
scp -p /az/web/ezap.abc.com/docs/*.gif saloo:/az/web/vendornet.abc.com/docs/tester/bkup

if [ $? != 0 ]; then
echo "error occurred"
mailx -s "Subject" "abc@abc.com" <<-EOT
scp failed
`date`
EOT

scp1=1
fi


scp -p recon:/az/web/vendornet.abc.com/docs/tester/mike/priceops/*.txt audi:/az/web/ezap.abc.com/docs

if [ $? != 0 ]; then
echo "error occurred"
mailx -s "Subject" "abc@abc.com" <<-EOT
scp failed
`date`
EOT

scp2=1

fi

if [ scp1 = 0 ]; then
echo "First SCP successful" >> $LOCAL_LOG_FILE
fi

if [ scp2 = 0 ]; then
echo "Second SCP successful" >> $LOCAL_LOG_FILE
fi
# 10  
Old 01-20-2008
Thanks you. I read the man command on mail and was able to find the solution

Last edited by chris1234; 02-24-2009 at 01:00 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Unable to send mail with 'mail' command

I am unable to cause the 'mail' command to send mail from my linux ubuntu 15.10 computer. File 'mail.log' typically reports Connection timed out. I issue the command: mail -s "my subject" recipient@domain.com < filenamewhere filename is a file containing my message. Specifically, the... (3 Replies)
Discussion started by: tcnm
3 Replies

2. Linux

A simple question about mail command

Simple question: i read mail n°4,how to return to list of messages? (2 Replies)
Discussion started by: Linusolaradm1
2 Replies

3. Homework & Coursework Questions

Creating a function that sends a mail using mail command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The function will be called m and it will allow you to send an email to someone using the mail command. The... (1 Reply)
Discussion started by: Drucian
1 Replies

4. Shell Programming and Scripting

Not able to send the mail using mail and mailx command

Hi All, I am trying to send a mail from linux server but could'nt able to send the mail. I tried the below syntax's so far but no luck. mail -s “Hello world” abc@xyz.com < /usr/g/txt.log cat "txt.log" | mailx -s "Hello world" abc@xyz.com mailx -s “Hello world” abc@xyz.com <... (2 Replies)
Discussion started by: scriptscript
2 Replies

5. Solaris

identify the mail server for mail command

Hi , I am new to unix , i am using the mail and mailx command to send the mail .How come i will know the my mail command using which server as mail box.. Please help me .. Thanks in advance (1 Reply)
Discussion started by: julirani
1 Replies

6. Shell Programming and Scripting

Help with SCP command

Hi, I have around 100 files which are aroun 10 MB in size and need to SCP all those files to another machine. Could you please suggest which way is efficient to do? 1. Gzip each file and transfer one by one. 2. Tar all the files together and then gzip it and send one HUGE file. Basicaly... (3 Replies)
Discussion started by: robinbannis
3 Replies

7. Solaris

SSH/SCP Question

Thanks to this forum, I was able to get a program running that uses SSH to control programs running on other hosts. Now I'd like to enhance it. The control program on the target hosts occassionally needs to be updated. Updating the menu program on the source host is easy as it is on one host. ... (1 Reply)
Discussion started by: PabloCruise77
1 Replies

8. Shell Programming and Scripting

scp shell scripting question

HI all, I am attempting to use the scp statemet in a shell script that I am writing I need to have the user of the script enter a password at the time of the shell script running.I have the following questions? 1) how do i disable the automatic text echo when the user is entering the... (1 Reply)
Discussion started by: Segwar
1 Replies

9. UNIX for Dummies Questions & Answers

Simple Windows-to-Unix SCP question

Hi, I am fairly new to Unix. My school computers have only UNIX installed on them, and I wish to use them to do some parallel computing. To do so, I need to transfer the files from my Windows computer to my Unix account on a different computer. I am using the SSH login with the Putty client.... (2 Replies)
Discussion started by: Duchesne
2 Replies

10. UNIX for Dummies Questions & Answers

cipher scp question

Hi, At the moment there are two ciphers available on our unix box (aix 5.1)...aes256 and 3des. Can somebody tell how can use a different cipher (aes128 one that use less cpu and is faster). How do i install this. How can i see wich ciphers are available. In the config file of ssh2 the folowwing... (0 Replies)
Discussion started by: lennyxx
0 Replies
Login or Register to Ask a Question