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
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 01:14 PM
Untar remotely jwzumwalt Shell Programming and Scripting 3 03-19-2008 03:11 PM
how to use cvs export remotely jasongr Shell Programming and Scripting 2 11-27-2005 08:41 PM
Having PROM Env remotely ! nikk UNIX for Advanced & Expert Users 1 11-11-2001 03:19 PM
Remotely login to one from another? Kagor UNIX for Dummies Questions & Answers 2 01-17-2001 06:39 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 10-22-2004
dxrmroue dxrmroue is offline
Registered User
  
 

Join Date: Jul 2001
Posts: 8
if statement remotely

I need to rsh to many machines and run an " if statement' that checks the versions of the OS and if up to date it tee -a to a file called "uptodate"..then if not update, it tee -a to file called "notuptodate" on my machine

the command that checks the version is cat /etc/version.
now the output of that is the one I am looking to have the if statement test against.

I am just having issues with setting up that if statement
This is part of it..( variable are already set up )

for host in `cat $SUN`
do
rsh $host "( /usr/bin/cat /etc/version)"

***problem starts here**
if [$? = 5.8]; then
echo $host | tee -a $uptodate
else
echo $host | tee -a $notuptodate
fi
done

Your help would be appreciated
  #2 (permalink)  
Old 10-22-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Hmm. You're testing the value of $? which is the exit code of the command - this is never going to be equal to 5.8

Something like
version=`rsh $host "( /usr/bin/cat /etc/version)"`
if [ "$version" -eq "5.8" ]; then
# version 5.8
else
# some other version
fi
# etc

might do it - this is untested though

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 08:04 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