Sponsored Content
Top Forums UNIX for Advanced & Expert Users script dies prematurely and unpredictably Post 302357420 by mlw63@me.com on Tuesday 29th of September 2009 07:29:32 PM
Old 09-29-2009
script dies prematurely and unpredictably

Hi,

I have over 5 gb of data in a files structure in which month folders are in year folders, day folders are in month folders, and individual climate stations are in each day. I am trying to extract precipitation measured at 5 minute intervals for a duration of 15 years, but the script never gets beyond the fifth year. I have run it many many times in Snow Leopard Terminal 2.1 (272). It stops at:
+ echo STIL 89 570 85 13.5 0.7 0.7 137 5.0 0.2 1.0 0.00 -999.00 1 14.4 0.0 15.6 18.2 15.4 16.5 15.8

Here is the script:
#!/bin/ksh -x
Myoutput=/MyOutput/MyOutput_$$.txt
cd ../wine
# takes output of ls command and pass to next line

ls |\

while read nextyear

do
Year=${nextyear}
cd ${nextyear}
ls |\
while read nextmonth
do
Month=${nextmonth}
cd ${nextmonth}
ls |\
while read nextday
do
Day=${nextday}
cd ${nextday}
ls | grep stil | xargs grep -i stil |\
while read nextline
do



Stid=`echo ${nextline} | awk '{print $1}'`
Time=`echo ${nextline} | awk '{print $3}'`
Rain=`echo ${nextline} | awk '{print $12}'`
echo ${Stid} ${Year} ${Month} ${Day} ${Time} ${Rain} >> $Myoutput

done


cd ..
done
cd ..
done
cd ..
done

This is how the output is supposed to look:
STIL 1994 01 01 0 0.00
STIL 1994 01 01 5 0.00
STIL 1994 01 01 10 0.00
STIL 1994 01 01 15 0.00
STIL 1994 01 01 20 0.00
STIL 1994 01 01 25 0.00
STIL 1994 01 01 30 0.00
STIL 1994 01 01 35 0.00
STIL 1994 01 01 40 0.00
STIL 1994 01 01 45 0.00
STIL 1994 01 01 50 0.00
STIL 1994 01 01 55 0.00
STIL 1994 01 01 60 0.00
STIL 1994 01 01 65 0.00
STIL 1994 01 01 70 0.00
STIL 1994 01 01 75 0.00
STIL 1994 01 01 80 0.00
STIL 1994 01 01 85 0.00
STIL 1994 01 01 90 0.00
STIL 1994 01 01 95 0.00
STIL 1994 01 01 100 0.00
STIL 1994 01 01 105 0.00
STIL 1994 01 01 110 0.00
STIL 1994 01 01 115 0.00
STIL 1994 01 01 120 0.00
STIL 1994 01 01 125 0.00
STIL 1994 01 01 130 0.00
STIL 1994 01 01 135 0.00
STIL 1994 01 01 140 0.00
STIL 1994 01 01 145 0.00
STIL 1994 01 01 150 0.00
STIL 1994 01 01 155 0.00
STIL 1994 01 01 160 0.00
STIL 1994 01 01 165 0.00
STIL 1994 01 01 170 0.00
STIL 1994 01 01 175 0.00
STIL 1994 01 01 180 0.00
STIL 1994 01 01 185 0.00
STIL 1994 01 01 190 0.00
STIL 1994 01 01 195 0.00
STIL 1994 01 01 200 0.00
STIL 1994 01 01 205 0.00
STIL 1994 01 01 210 0.00
STIL 1994 01 01 215 0.00
STIL 1994 01 01 220 0.00
STIL 1994 01 01 225 0.00
STIL 1994 01 01 230 0.00
STIL 1994 01 01 235 0.00
STIL 1994 01 01 240 0.00
STIL 1994 01 01 245 0.00
STIL 1994 01 01 250 0.00
STIL 1994 01 01 255 0.00
STIL 1994 01 01 260 0.00

Any ideas? I just need it to run through 10 more years of data!

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why does rexec cause while loop to end prematurely?

I have the following korn shell script which reads the contents of an ascii file and performs an rexec command based on the line that was just read from the ascii file. The ascii file contains 6 lines, thus, the while loop should execute 6 times. The problem is that the rexec command within the... (2 Replies)
Discussion started by: sadove
2 Replies

2. Solaris

daemon dies, need to know why

Say I have a daemon that dies for an unknown reason. Is there a way to track its process ID to try to determine when it dies and what causes it to go away? (2 Replies)
Discussion started by: Silver11
2 Replies

3. Shell Programming and Scripting

script to change default route when primary gateway dies

Hello all! We have two fedora routers one at each site. What we are trying to do worked using freesco but not on fedora, i'm not very good at scripting and need a little guidence. Basicly what we are trying to do is if the primary line dies, the router will change it's routes to go through our... (0 Replies)
Discussion started by: slacker
0 Replies

4. UNIX for Dummies Questions & Answers

perl script dies altogether when I put an & after it

ignore (2 Replies)
Discussion started by: hairytorus
2 Replies

5. Programming

nanosleep returns prematurely, with return value 0

Hi, I have encountered the following problem on Solaris 10: I have a thread that is asleep on nanosleep (set to 24 hours). Something that happens on another thread, causes the nanosleep to exit, even though the time has not elapsed. The returned value is 0 (so it doesn't look like it... (1 Reply)
Discussion started by: MeMyself
1 Replies

6. Infrastructure Monitoring

Nagios escalating prematurely

We are currently using Nagios 1.3 .The issue we facing is , when a alert is in Warning state and then from Warning it moves to Critical state ,the alert is escalated directly to L2,L3 L4 escalations,here nagios assumes that the time period ,the alert was in warning state as unacknowledged time... (0 Replies)
Discussion started by: apatil
0 Replies

7. Shell Programming and Scripting

Background program exits prematurely?

Hello! I am currently attempting to build a very, very, basic program that attempts to act like a calendar for a "server." Using this program I need to have the client program connect to the server program, have the client wait for the server to respond through a socket, then exit and the server... (2 Replies)
Discussion started by: Entelexia
2 Replies

8. Shell Programming and Scripting

Expect script cronjob running but dying prematurely

I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does: aptitude update && aptitude upgrade while answering "yes" at the appropriate time. It works quite nicely when run... (4 Replies)
Discussion started by: CluelessPerson
4 Replies

9. Shell Programming and Scripting

[Solved] Process dies when launched in system startup script

Good morning! I'm trying to add Maven to the system boot by the moment without success. Testing the operation of the script I realize that the process isn't persistent when the program is launched with the start option. ---- #Startup Script ---- #! /bin/sh # chkconfig: 345 99 1 #... (5 Replies)
Discussion started by: carpannav
5 Replies

10. UNIX for Advanced & Expert Users

Xterm dies after being idle

I am running eod8 to connect to a linux machine running carnesr==>uname -a Linux hostname 2.6.32-220.2.1.el6.x86_64 #1 SMP Tue Dec 13 16:21:34 EST 2011 x86_64 x86_64 x86_64 GNU/Linux I have a script that opens up several xterms as follows: /usr/bin/xterm -geometry 150x60+0-0 -name... (1 Reply)
Discussion started by: rcarnesiii
1 Replies
curl_getdate(3) 						  libcurl Manual						   curl_getdate(3)

NAME
curl_getdate - Convert a date string to number of seconds since January 1, 1970 SYNOPSIS
#include <curl/curl.h> time_t curl_getdate(char *datestring, time_t *now ); DESCRIPTION
This function returns the number of seconds since January 1st 1970 in the UTC time zone, for the date and time that the datestring parame- ter specifies. The now parameter is not used, pass a NULL there. NOTE: This function was rewritten for the 7.12.2 release and this documentation covers the functionality of the new one. The new one is not feature-complete with the old one, but most of the formats supported by the new one was supported by the old too. PARSING DATES AND TIMES
A "date" is a string containing several items separated by whitespace. The order of the items is immaterial. A date string may contain many flavors of items: calendar date items Can be specified several ways. Month names can only be three-letter english abbreviations, numbers can be zero-prefixed and the year may use 2 or 4 digits. Examples: 06 Nov 1994, 06-Nov-94 and Nov-94 6. time of the day items This string specifies the time on a given day. You must specify it with 6 digits with two colons: HH:MM:SS. To not include the time in a date string, will make the function assume 00:00:00. Example: 18:19:21. time zone items Specifies international time zone. There are a few acronyms supported, but in general you should instead use the specific relative time compared to UTC. Supported formats include: -1200, MST, +0100. day of the week items Specifies a day of the week. Days of the week may be spelled out in full (using english): `Sunday', `Monday', etc or they may be abbreviated to their first three letters. This is usually not info that adds anything. pure numbers If a decimal number of the form YYYYMMDD appears, then YYYY is read as the year, MM as the month number and DD as the day of the month, for the specified calendar date. EXAMPLES
Sun, 06 Nov 1994 08:49:37 GMT Sunday, 06-Nov-94 08:49:37 GMT Sun Nov 6 08:49:37 1994 06 Nov 1994 08:49:37 GMT 06-Nov-94 08:49:37 GMT Nov 6 08:49:37 1994 06 Nov 1994 08:49:37 06-Nov-94 08:49:37 1994 Nov 6 08:49:37 GMT 08:49:37 06-Nov-94 Sunday 94 6 Nov 08:49:37 1994 Nov 6 06-Nov-94 Sun Nov 6 94 1994.Nov.6 Sun/Nov/6/94/GMT Sun, 06 Nov 1994 08:49:37 CET 06 Nov 1994 08:49:37 EST Sun, 12 Sep 2004 15:05:58 -0700 Sat, 11 Sep 2004 21:32:11 +0200 20040912 15:05:58 -0700 20040911 +0200 STANDARDS
This parser was written to handle date formats specified in RFC 822 (including the update in RFC 1123) using time zone name or time zone delta and RFC 850 (obsoleted by RFC 1036) and ANSI C's asctime() format. These formats are the only ones RFC2616 says HTTP applications may use. RETURN VALUE
This function returns -1 when it fails to parse the date string. Otherwise it returns the number of seconds as described. If the year is larger than 2037 on systems with 32 bit time_t, this function will return 0x7fffffff (since that is the largest possible signed 32 bit number). Having a 64 bit time_t is not a guarantee that dates beyond 03:14:07 UTC, January 19, 2038 will work fine. On systems with a 64 bit time_t but with a crippled mktime(), curl_getdate will return -1 in this case. REWRITE
The former version of this function was built with yacc and was not only very large, it was also never quite understood and it wasn't pos- sible to build with non-GNU tools since only GNU Bison could make it thread-safe! The rewrite was done for 7.12.2. The new one is much smaller and uses simpler code. libcurl 7.0 12 Aug 2005 curl_getdate(3)
All times are GMT -4. The time now is 08:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy