Need help adding alert on the attached script - Solaris 10
Hi I have this script that does the FTP to another server and wanted to know where I can add an alert that sends email to me if it failed and or successful.
bash-3.00# more 1order #!/bin/sh pid=`ps -ef | grep "/bin/sh $0" | grep -v grep | grep -v $$` if [ -n "$pid" ]; then exit 1; fi cd /extra/home/remisol/order1 ls -1 * >/extra/home/remisol/listord.txt echo "user sunftp sunftp" >/extra/home/remisol/ftpord.cmd echo "cd ORDER1" >> /extra/home/remisol/ftpord.cmd echo "bin" >> /extra/home/remisol/ftpord.cmd while read myline do echo $myline echo "put "$myline >> /extra/home/remisol/ftpord.cmd echo "cd ../ORDER3" >> /extra/home/remisol/ftpord.cmd echo "put "$myline >> /extra/home/remisol/ftpord.cmd echo "cd ../ORDER2" >> /extra/home/remisol/ftpord.cmd echo "put "$myline >> /extra/home/remisol/ftpord.cmd echo "cd ../BKP_ORDERS" >> /extra/home/remisol/ftpord.cmd echo "put "$myline >> /extra/home/remisol/ftpord.cmd echo "cd ../ORDER1" >> /extra/home/remisol/ftpord.cmd done < /extra/home/remisol/listord.txt echo "quit" >> /extra/home/remisol/ftpord.cmd ftp -n 192.1.2.185 < /extra/home/remisol/ftpord.cmd sleep 10 while read myline do # cp /extra/home/remisol/order1/$myline /extra/home/remisol/logs/order1 mv /extra/home/remisol/order1/$myline /extra/home/remisol/backup/order1 done < /extra/home/remisol/listord.txt Thanks in advance |
Theoretically after every line ;)
But seriously this is the key cmd Code:
ftp -n 192.1.2.185 < /extra/home/remisol/ftpord.cmd Don't understand why the 'sleep 10' is there??? |
Please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
I'm not going to immediately address the OP, but I just can't stand to see poorly-written scripts, so I was compelled to rewrite it. See the comments I added for descriptions of the changes and other recommendations. Code:
#!/bin/bash |
All times are GMT -5. The time now is 04:19 PM. |