0

i want to write bash file perform the following steps :-

copy file from server1 to server2

if (copy success )

do nothing

if (copy failed )

send e-mail to admin@company.com contain the following information

file name [copy failed]

Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54

1 Answers1

5

On server1 --

SOURCE=a.txt
DEST=a.txt
R_HOST=server2

scp $SOURCE $R_HOST:$DEST || mutt -s "[copy failed] Copy of $SOURCE failed" admin@company.com

Requires you have mutt installed. If you don't, get mutt, or replace the mutt portion with a sendmail alternative.

linkedlinked
  • 446
  • 1
  • 3
  • 11