This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Executing JAVA code from shell script and grep the result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Executing JAVA code from shell script and grep the result" Watch "Executing JAVA code from shell script and grep the result" New topic
Author

Executing JAVA code from shell script and grep the result

P B Madhavan
Greenhorn

Joined: Dec 23, 2009
Posts: 5
Hi All,

I am new to Unix. I have a question

I have a requirement to execute a JAVA class from Unix shell script.

I need to then grep for a key word "NOTOK" that is rendered by a System.out.println statement of the JAVA Class.

If I find the word, then I need to echo a message.

Could you kindly help me with this requirement?


Regards,

Madhavan
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

java my.app.MainClass | grep NOTOK && echo "something"

Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Executing JAVA code from shell script and grep the result
 
Similar Threads
How return a string from java program to the shell which invokes thee java command
any java method which can work like grep command in unix
issue in passiing variable to shell script
Perl regex
issue when calling shell script from java