The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh: cmd output to input of another script IMTheNachoMan Shell Programming and Scripting 2 04-27-2008 09:58 AM
log script input and output using tee ? moseschrist Shell Programming and Scripting 0 11-12-2006 03:32 AM
Asking about shell script input output redirection trivektor Shell Programming and Scripting 1 10-18-2006 01:13 AM
Input to shell script castlerock Shell Programming and Scripting 3 04-03-2006 05:26 AM
single input shell script? quipy Shell Programming and Scripting 1 10-03-2002 08:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-10-2008
aspect_p aspect_p is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 13
Shell script getting input from output

I have a program that can be run in terminal, when its run it either returns SSH OK or CRITICAL, how do i use the output in my script?

good
./check_sh myserver
SSH OK

bad
./check_sh myserver
CRITICAL

I want to store it in a variable btw, SSH OK will give the variable $SSH=1 and if its critical $SSH=0
  #2 (permalink)  
Old 03-11-2008
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Code:
#! /bin/bash

RESULT=$( /absolute/path/to/check_sh myserver )

case ${RESULT} in
   "SSH OK" ) SSH=1 ;;
   "CRITICAL" ) SSH=0 ;;
   * ) SSH=<some_other_value> ;;
esac
Also; convention would have "0" being a success, not a failure as you have it.

Cheers,
ZB
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0