if statement remotely


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if statement remotely
# 1  
Old 10-22-2004
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  
Old 10-22-2004
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. UNIX for Dummies Questions & Answers

Remotely Diff Two files

Daily Stupid Question: How can I remotely look at the difference from a file from my localhost and a remote machine? So: diff local-file remote-file-on-some-other-ip (2 Replies)
Discussion started by: metallica1973
2 Replies

3. Shell Programming and Scripting

Need help to execute the shell remotely

Hi All, I have a typical problem where I have HP unix and want to connect to Solaris 5.10 box and run a shell. I tried with multiple forums but it does not help. As per my analysis, there is no ssh in my machine and so i cant connect to solaris box,secondly ftp to the solaris server is not... (2 Replies)
Discussion started by: cskumar
2 Replies

4. Solaris

SSH Remotely

Hello. I am trying to ssh and run a script from a remote computer. These computers will be both Windows and MACs. I am using Solaris 8 and what I have tried is: using putty ssh user@ip_address (remote command) /folder/folder/filename.sh The issue here is that the user profile has not... (3 Replies)
Discussion started by: jkmtm
3 Replies

5. Shell Programming and Scripting

using awk remotely

Hi there I am trying to add up the disk space used on a remote linux box but am falling at the first hurdle i.e isolating the 'space used' column with df -k on the remote box if i run this, i get the df -k output as expected # rsh remote-server 'df -k|grep sd|grep -v boot' /dev/sda3 ... (8 Replies)
Discussion started by: hcclnoodles
8 Replies

6. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

7. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

8. Shell Programming and Scripting

Untar remotely

I need to upload tar or zip files to a unix server than unzip or untar them remotely. Any suggestions on the easiest way to do the remote untar or unzip? For example does someone know of a cgi script or something? Thanks -jz (3 Replies)
Discussion started by: jwzumwalt
3 Replies

9. UNIX for Advanced & Expert Users

Using CD drive remotely !

hi, could anyone tell me that how can i use a remote CD drive for installing solaris , cause my local Drive has peroblem. tell me the steps one by one. Rgrds, nikk:confused: (6 Replies)
Discussion started by: nikk
6 Replies

10. UNIX for Dummies Questions & Answers

Remotely login to one from another?

NT CONSULTANT IS NEAR TOTAL UNIX NEWBIE! Please help! I would like detailed info about how to remotely connect a PC running win'98 that is not on a local network to a unix server which is locally networked to other PCs? Would like to know how to: Move files back and forth? Mount... (2 Replies)
Discussion started by: Kagor
2 Replies
Login or Register to Ask a Question