Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Bash script...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 2105 of 2371
Post > Topic >>

Re: Bash script timing out

by cozzmo1@[EMAIL PROTECTED] Dec 21, 2007 at 08:54 AM

On Dec 19, 6:44 pm, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
> On 12/19/2007 12:47 PM, cozz...@[EMAIL PROTECTED]
 wrote:
>
>
>
> > Perhaps someone could help with this.
> > This script times out.
>
> > #!/bin/bash
> > cat ~/$1 |  while  read line
> > do
> > if [[ "$line" != /*/*/**Closed* && "$line" != "" &&  "$line" != *Auto?
> > Closed* ]]
> >  then
> > {
> > if [[ "$line" == [1-6][0-9][0-9][0-9][0-9]\,*[a-z,A-Z]* ]]
> > then
> > {
> > read ticket date time <<EOF
> > $(echo "$line" | nawk 'BEGIN { FS = "," } ; { print  $1,  $6, $7 }')
> > EOF
> > echo "$ticket" "$date" "$time" "Opened"
> > }
> > elif [[  "$line" == \*\*\**Not?Approved* ]]
> > then
> > {
> > echo "$line" | nawk '{ print "$ticket" " " $4 " " $5 " " "Not-
> > Approved" }'
> > }
> > elif [[  "$line" ==  \*\*\**Picked?Up* || "$line" == \*\*\**Complete*
> > || "$line" == \*\*\**Approved*  ]]
> > then
> > {
> > echo "$ticket" "$line" | nawk '{ print $1 " " $5 " " $6 " " $8 }'
> > }
> > fi
> > }
> > fi
> > done
>
> > ---------
> > Output:  (note yak1 is a very huge file, and I am just trying to get
> > the facts out.)
>
> > $ temp2 yak1
> > <snip>
> > 32626 2007-09-26 10:57:00 Opened
> > 32626 09-26-2007 12:23 Picked
> > 32626 09-26-2007 12:47 Approved
> > 32626 09-27-2007 01:51 Complete
> > 32627 2007-09-26 11:16:00 Opened
> > 32627 09-26-2007 11:30 Picked
> > 32627 09-26-2007 11:30 Approved
> > 32627 09-26-2007 11:41 Complete
> > 32628 2007-09-26 11:20:00 Opened
> > 32628 09-26-2007 11:29 Picked
> > 32628 09-26-2007 11:29 Approved
> > 32628 09-26-2007 11:46 Complete
> > <output ends here>
> > but the file hasn't even been half parsed, if I pipe this to a file,
> > then it ends sooner (32635).
>
> > This seems to have started after I added these items in order to print
> > from the variables instead of just rendering straight to print.
> > read ticket date time <<EOF
> > EOF
> > echo "$ticket" "$date" "$time" "Opened"
>
> > I am sure it has nothing to do with the input file.
> > but don't know why it hangs.
> > maybe there is a buffer that fills up because of the variables??
>
> > Thanks,
> >crzzy1
>
> I suspect it has to do with you trying to read from your here do***ent
at the
> same time as you're reading from you UUOC pipe, but whatever the problem
is it's
> a shell one, not an awk one so you'll get a better answer at a shell NG
such as
> comp.unix.shell.
>
> Having said that, I'm sure you'd get a much better result if you just
rewrite
> the script in awk. It looks like what you're trying to do (directly
translating
> your script) is:
>
> awk '
> !/^\*\*\*.*Closed/ && !/^$/ && !/Auto.Closed/ {
>    if (/^[1-6][0-9][0-9][0-9][0-9],.*[a-z,A-Z]*$) {
>       split($0,f,",")
>       ticket = f[1]
>       print ticket,f[6],f[7],"Opened"
>    } else if (/^\*\*\*.*Not.Approved*/) {
>       print ticket,$4,$5,"Not-Approved"
>    } else if
(/^\*\*\*.*Picked.Up/||/\*\*\*.*Complete/||/\*\*\*.*Approved/) {
>       print ticket,$5,$6,$8
>    }}
>
> ' "$1"
>
> If so, that can be made a bit more readable (IMHO) as:
>
> awk '
> /(^\*\*\*.*|Auto.)Closed|^$/ {
>       next}
>
> /^[1-6][0-9][0-9][0-9][0-9],.*[a-z,A-Z]*$) {
>       split($0,f,","); print f[1],f[6],f[7],"Opened"
>       next}
>
> /^\*\*\*.*Not.Approved*/ {
>       print f[1],$4,$5,"Not-Approved"
>       next}
>
> /^\*\*\*.*(Picked.Up|Complete|Approved)/ {
>       print f[1],$5,$6,$8
>       next}
>
> ' "$1"
>
> You may need to tweak the conditions to be exactly what you're looking
for. If
> you'd like more help, post a small set of sample input to match your
expected
> output.
>
> Regards,
>
>         Ed.

-----------
Thanks for doing that Ed,

I tried, but can't seem to get it to work, I like the first one as I
seem to be able to follow the logic with it pretty well.
when I try the first one (saved as "ttt"), I get

$ ttt yak1
awk: syntax error near line 3
awk: illegal statement near line 3
awk: syntax error near line 7
awk: bailing out near line 7

Second one gives.
 ttt yak1
awk: syntax error near line 6
awk: bailing out near line 6
awk: newline in regular expression near line 6

Crzzy1
 




 7 Posts in Topic:
Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2007-12-19 10:47:04 
Re: Bash script timing out
Kees Nuyt <k.nuyt@[EMA  2007-12-19 21:19:12 
Re: Bash script timing out
Ed Morton <morton@[EMA  2007-12-19 17:44:46 
Re: Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2007-12-21 08:54:47 
Re: Bash script timing out
Ed Morton <morton@[EMA  2007-12-21 12:34:46 
Re: Bash script timing out
cozzmo1@[EMAIL PROTECTED]  2008-01-03 08:23:56 
Re: Bash script timing out
Ed Morton <morton@[EMA  2008-01-03 18:27:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 12:29:36 CDT 2008.