Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

catching screen output in a script 2

Status
Not open for further replies.

nimrodman

MIS
Nov 22, 2005
43
US
I was wondering if anyone can tell me how I can catch and use the return of a command, if I run a command and the return says SUCCESS, how can I catch that and say something like :

If the result is success do something if not exit, I know how to do the conditional statement, but I do not know how to catch the result, thanks.
 
The "expect" scripting-language can do that.


In the most basic form you build together
send and expect pairs of commands
to automate the interaction with something.
It can do decision-making also.

And with a script called autoexpect you can
"record" a conversation and make an expect-script that will
duplicate what was recorded.

HTH
 
Is the command interactive (do you have to type a bunch of stuff at it) or is it argument driven? If it is the latter, it is just a matter of saving stdout.

eugene
 
In other words:

Code:
somecommand > /tmp/somecommand.out
# grep quietly, for you search through my streams...
if grep -q SUCCESS /tmp/somecommand.out
then
    echo "somecommand was successful"
    # do some stuff
else
    echo "somecommand failed"
    exit 1
fi

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top