cron script can awk wget file but not head/cat it

Pagano, Tom - Portland, OR tom.pagano@por.usda.gov
Fri Sep 9 21:26:00 GMT 2005


 
I have a problem where I get one behavior when I run a file from a cron and another when I run it from the command line. Attached is my cygcheck.out file. 
 
When I run the following script from the command line:
 
------------------------
 
$ cat testscript.scr
mydir="/home/tompagano/test"
 
cd $mydir
rm sntl_data*
 
wget -E --http-user=anonymous --http-passwd=tpagano@ ftp://ftp.wcc.nrcs.usda.gov/pub/outgoing/chris/snotel/sntl_data.csv <ftp://ftp.wcc.nrcs.usda.gov/pub/outgoing/chris/snotel/sntl_data.csv> 
chmod 777 $mydir/sntl_data.csv

 cat            $mydir/sntl_data.csv >       $mydir/sntl_data_catted.csv
 cp             $mydir/sntl_data.csv         $mydir/sntl_data_copied.csv
 mv             $mydir/sntl_data.csv         $mydir/sntl_data_moved.csv
 cat            $mydir/sntl_data_moved.csv > $mydir/sntl_data_moved_then_catted.csv
 head -10       $mydir/sntl_data_moved.csv > $mydir/sntl_data_moved_then_headed.csv
 awk 'NR <= 10' $mydir/sntl_data_moved.csv > $mydir/sntl_data_moved_then_awked.csv
 
///////////////////////
 
I get output that looks just fine, as expected 
 
-----------------------
total 452K
-rw-r--r--  1 jim.marron None  22K Sep  9 11:51 cygcheck.out
-rw-r--r--  1 jim.marron None 103K Sep  9 13:09 sntl_data_catted.csv
-rwxr-xr-x  1 jim.marron None 103K Sep  9 13:09 sntl_data_copied.csv*
-rwxrwxrwx  1 jim.marron None 103K Sep  9 13:09 sntl_data_moved.csv*
-rw-r--r--  1 jim.marron None 1.6K Sep  9 13:09 sntl_data_moved_then_awked.csv
-rw-r--r--  1 jim.marron None 103K Sep  9 13:09 sntl_data_moved_then_catted.csv
-rw-r--r--  1 jim.marron None 1.6K Sep  9 13:09 sntl_data_moved_then_headed.csv
-rwxrwxrwx  1 jim.marron None  664 Sep  9 13:09 testscript.scr*
////////////////////////
 
Note the size of the files. I imagine everyone's familiar with awk, but the command is essentially the same as head -10, i.e. print out the first 10 lines. However, if I run this on a cron, like 
 
* * * * * /home/tompagano/test/testscript.scr > /tmp/cron.log
 
I get the following output 
 
------------------------
$ ls -l
total 241K
-rw-r--r--  1 jim.marron None  22K Sep  9 11:51 cygcheck.out
-rw-rw-rw-  1 jim.marron None    0 Sep  9 13:18 sntl_data_catted.csv
-rwxrwxrwx  1 jim.marron None 103K Sep  9 13:18 sntl_data_copied.csv*
-rwxrwxrwx  1 jim.marron None 103K Sep  9 13:18 sntl_data_moved.csv*
-rw-rw-rw-  1 jim.marron None 1.6K Sep  9 13:18 sntl_data_moved_then_awked.csv
-rw-rw-rw-  1 jim.marron None    0 Sep  9 13:18 sntl_data_moved_then_catted.csv
-rw-rw-rw-  1 jim.marron None   59 Sep  9 13:18 sntl_data_moved_then_headed.csv
-rwxrwxrwx  1 jim.marron None  664 Sep  9 13:09 testscript.scr*
/////////////////////////
 
And sntl_data_moved_then_headed.csv contains: Cannot open file /home/tompagano/test/sntl_data_moved.csv
This is a simplification of a much broader script I've been trying to run that was failing, but I've been able to isolate it down to this specific problem. I'm quite baffled as to why moving then awking a file would give a different result than catting or heading. It doesn't appear to be a permissions issue as far as I can tell because I can still move the files around? Am I missing something here? 
 
Thanks
 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 21992 bytes
Desc: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20050909/97e35162/attachment.obj>
-------------- next part --------------
--
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