Bash script help?



Hello -
I wrote this script to copy a file from my desktop to my nfs storage.
The problem is when i intentionally put the "sleep 3" line in my
script I expect it to send a email saying writing to the nfs took
longer than 2 seconds but it doesn't. It seems that i can't pass the
variable over? Do I need to re-write this in perl? Can anyone point me
to some literature or have some suggestions? Thanks!

#!/usr/bin/ksh
COMMAND=$(cp /u/dchun/file.txt /10.0.0.4/stuff/file.txt)
start_time=$(date +"%Y%m%d%H%M%S")

if [ "$COMMAND" != '' ]; then

message="NAS write failure TIME $(date +"%Y%m%d%H%M%S")"
echo "$message"| mail -s "ALERT: Can't write to NAS"
sam@xxxxxxxxx
sleep 3
stop_time=$(date +"%Y%m%d%H%M%S")
total_time=`expr $stop_time - $start_time`

elif [ "$total_time" -gt 2 ]; then

message="NAS write took too long $(date +"%Y%m%d%H%M%S")"
echo "$message"| mail -s "ALERT: Writing to NAS took longer
than 2 seconds" sam@xxxxxxxxx

else message="NAS OK"

fi

echo $(date +"%Y%m%d%H%M%S"):$message >> /u/dchun/cron/nfs_check.log
.



Relevant Pages

  • Re: Bash script help?
    ... elroyerni wrote: ... I wrote this script to copy a file from my desktop to my nfs storage. ... The problem is when i intentionally put the "sleep 3" line in my ...
    (comp.unix.shell)
  • Re: Bash script help?
    ... I wrote this script to copy a file from my desktop to my nfs storage. ... The problem is when i intentionally put the "sleep 3" line in my ... therefore, if the command IS defined, ...
    (comp.unix.shell)
  • Re: Sleep command quitting
    ... It cannot be that the `sleep` command is terminating. ... That script was popular when I started working at SCO Support in 1989. ... it doesn't really hold the settings you specify. ... anything else comes along and makes further changes, the holdopen script ...
    (comp.unix.sco.misc)
  • Re: WScript.dll not working
    ... But, when i call a script indirectly in my application's exe's context, then it doesn't repond further. ... the sleep method is coded into the ... could call the sleep api directly from script. ...
    (microsoft.public.scripting.vbscript)
  • my script crashes when I try to rename the file!
    ... OK, thanks, but the script does not seem to rename the files. ... You can set the working directory from within your Perl ... # sleep 1; ... to the string in this particular file that I want to match. ...
    (perl.beginners)