trouble running a script with a while loop from cron
Mark Horning
mhorning@markwest.com
Mon Jul 21 21:15:00 GMT 2008
Hi All,
I've a problem with a script and I've been trying to troubleshoot it.
When I run it by hand it works fine but it fails from cron. From what i
can gather it doesn't like my while loop and the error I'm logging is
"The system cannot find the file specified". Here are the particulars:
*****************************************
The script:
#!/bin/bash
#
set -x
RTMP=/nmon/tmp
date +%m%d%Y
echo tpA
ls $RTMP/*nmon | cut -d. -f3 | sort -u | while read day; do
echo tpB
MON=$(echo $day | cut -c 1,2)
YEAR=$(echo $day | cut -c 5-)
echo tpC
echo $MON
echo $YEAR
echo
done
*****************************************
Here's the output when run by hand:
07212008
tpA
tpB
tpC
07
2008
tpB
tpC
07
2008
tpB
tpC
07
2008
*****************************************
Here's the output when run by hand with set -x :
+ RTMP=/nmon/tmp
+ date +%m%d%Y
07212008
+ echo tpA
tpA
+
ls /nmon/tmp/server1.daily.07182008.nmon /nmon/tmp/server1.daily.07192008.nmon /nmon/tmp/server1.daily.07202008.nmon /nmon/tmp/server2.daily.07182008.nmon /nmon/tmp/server2.daily.07192008.nmon /nmon/tmp/server2.daily.07202008.nmon /nmon/tmp/tserver1.daily.07182008.nmon /nmon/tmp/tserver1.daily.07192008.nmon /nmon/tmp/tserver1.daily.07202008.nmon /nmon/tmp/tserver2.daily.07182008.nmon /nmon/tmp/tserver2.daily.07192008.nmon /nmon/tmp/tserver2.daily.07202008.nmon /nmon/tmp/tserver3.daily.07182008.nmon /nmon/tmp/tserver3.daily.07192008.nmon /nmon/tmp/tserver3.daily.07202008.nmon /nmon/tmp/vio1.daily.07182008.nmon /nmon/tmp/vio1.daily.07192008.nmon /nmon/tmp/vio1.daily.07202008.nmon
+ cut -d. -f3
+ sort -u
+ read day
+ echo tpB
tpB
++ echo 07182008
++ cut -c 1,2
+ MON=07
++ echo 07182008
++ cut -c 5-
+ YEAR=2008
+ echo tpC
tpC
+ echo 07
07
+ echo 2008
2008
+ echo
+ read day
+ echo tpB
tpB
++ echo 07192008
++ cut -c 1,2
+ MON=07
++ echo 07192008
++ cut -c 5-
+ YEAR=2008
+ echo tpC
tpC
+ echo 07
07
+ echo 2008
2008
+ echo
+ read day
+ echo tpB
tpB
++ echo 07202008
++ cut -c 1,2
+ MON=07
++ echo 07202008
++ cut -c 5-
+ YEAR=2008
+ echo tpC
tpC
+ echo 07
07
+ echo 2008
2008
+ echo
+ read day
*****************************************
Here's the output captured from cron along with the error:
+ RTMP=/nmon/tmp
+ date +%m%d%Y
07212008
+ echo tpA
tpA
+
+
ls /nmon/tmp/server1.daily.07182008.nmon /nmon/tmp/server1.daily.07192008.nmon /nmon/tmp/server1.daily.07202008.nmon /nmon/tmp/server2.daily.07182008.nmon /nmon/tmp/server2.daily.07192008.nmon /nmon/tmp/server2.daily.07202008.nmon /nmon/tmp/tserver1.daily.07182008.nmon /nmon/tmp/tserver1.daily.07192008.nmon /nmon/tmp/tserver1.daily.07202008.nmon /nmon/tmp/tserver2.daily.07182008.nmon /nmon/tmp/tserver2.daily.07192008.nmon /nmon/tmp/tserver2.daily.07202008.nmon /nmon/tmp/tserver3.daily.07182008.nmon /nmon/tmp/tserver3.daily.07192008.nmon /nmon/tmp/tserver3.daily.07202008.nmon /nmon/tmp/vio1.daily.07182008.nmon /nmon/tmp/vio1.daily.07192008.nmon /nmon/tmp/vio1.daily.07202008.nmon
+ cut -d. -f3
+ sort -u
+ read day
-uThe system cannot find the file specified.
Any help is appreciated!,
Mark
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list