Computing.Net > Forums > Unix > shell script help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

shell script help

Reply to Message Icon

Name: esu (by Raj)
Date: November 28, 2007 at 16:44:12 Pacific
OS: Linux
CPU/Ram: AMD Dual Core 2.4gz
Product: x86_64
Comment:

Hello Linux users,

can someone help writing script for follwing issue.
I have one text file(abc.txt) which get updated when some third party program finish running. When external(third party) program doesn't successfully finish, the text file updated with additional line :
[munit] Test abc.tests.TestSuite FAILED

When external program finish execution successfully then text file doesn't include above line

I want to create shell script which check text file(abc.txt) to see if it contains above failure line, if it contains failure line then create another text file(xyz.txt) with just "FAILED" word in it. If text file(abc.txt) doesn't conat above failure line then abc.txt should contain only "PASSED"




Sponsored Link
Ads by Google

Response Number 1
Name: lankrypt0
Date: November 30, 2007 at 08:06:00 Pacific
Reply:

This should work fine. I was not sure if on PASSED you wanted it to go to xyz.txt or abc.txt so I assumed xyz.txt as that is where the failed status went to.

#!/usr/bin/ksh
case $(grep '\[munit\] Test abc.tests.TestSuite FAILED' < abc.txt) in
*[a-z]*)
print "FAILED" > xyz.txt
;;
*)
print "PASSED" > xyz.txt
;;
esac


0

Response Number 2
Name: esu (by Raj)
Date: November 30, 2007 at 15:22:39 Pacific
Reply:

Great ...this works as expected. Thanks.

Appreciated your time.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: shell script help

Shell Scripting Help www.computing.net/answers/unix/shell-scripting-help/5020.html

C Shell script help! www.computing.net/answers/unix/c-shell-script-help/3108.html

c shell script help PLEASE www.computing.net/answers/unix/c-shell-script-help-please/4355.html