X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Subject: trouble running a script with a while loop from cron From: Mark Horning To: cygwin AT cygwin DOT com Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Mon, 21 Jul 2008 15:14:52 -0600 Message-Id: <1216674892.17040.8.camel@explorer> Mime-Version: 1.0 X-Mailer: Evolution 2.22.0-4.1mdv2008.1 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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/