Unix Technical Forum

Scripting Help

This is a discussion on Scripting Help within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> I wrote something like this a long time ago but forgot what I did. I have a application that ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > Sun Solaris Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2008, 06:08 AM
Big Chuck
 
Posts: n/a
Default Scripting Help


I wrote something like this a long time ago but forgot what I did.

I have a application that generates a bunch of console output during
startup and then finally prints out a message like "Server started."
when done.

I want a startup script that will go into a while loop and grep for the
"Server started" string. One is sees that, echos a message to the screen
and exits. I am also running this command from a nohup so the script
will actually need to monitor nohup.out for the startup string.

I have the entire script written with the exception of the while loop.

Can anyone help me out? My bash is a bit rusty.

Thx
-CC

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-12-2008, 06:08 AM
Barry Margolin
 
Posts: n/a
Default Re: Scripting Help

In article <3F0DEAE2.5030705@echeeba.com>,
Big Chuck <ccarson@echeeba.com> wrote:
>
>I wrote something like this a long time ago but forgot what I did.
>
>I have a application that generates a bunch of console output during
>startup and then finally prints out a message like "Server started."
>when done.
>
>I want a startup script that will go into a while loop and grep for the
>"Server started" string. One is sees that, echos a message to the screen
>and exits. I am also running this command from a nohup so the script
>will actually need to monitor nohup.out for the startup string.
>
>I have the entire script written with the exception of the while loop.
>
>Can anyone help me out? My bash is a bit rusty.


while read line
do
if [[ $line = "Server started." ]]
then echo "It's started!"
break
fi
done < nohup.out

--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-12-2008, 06:08 AM
John Howells
 
Posts: n/a
Default Re: Scripting Help



Barry Margolin wrote:
>
> In article <3F0DEAE2.5030705@echeeba.com>,
> Big Chuck <ccarson@echeeba.com> wrote:
> >
> >I want a startup script that will go into a while loop and grep for the
> >"Server started" string. One is sees that, echos a message to the screen
> >and exits. I am also running this command from a nohup so the script
> >will actually need to monitor nohup.out for the startup string.
> >
> >I have the entire script written with the exception of the while loop.
> >
> >Can anyone help me out? My bash is a bit rusty.

>
> while read line
> do
> if [[ $line = "Server started." ]]
> then echo "It's started!"
> break
> fi
> done < nohup.out


If the "nohup.out" file is being added to while the script is run, as
the OP would seem to indicate, that will not work, as it will terminate
when it comes to the end of nohup.out as it then exists. It should be
something like:

tail +1f nohup.out | while read line
do
echo $line | egrep -s "Server started" && break
done
echo "It's started"

if "Server started" is only part of the message, or

tail +1f nohup.out | while read line
do
[[ "$line" = "Server started" ]] && break
done
echo "It's started"

if the line is guaranteed to contain only "Server started", so that it
tracks nohup.out while is is being created.

John Howells
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:20 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com