Register
It is currently Mon Jul 28, 2014 12:17 am

Stupid simple SSH script?...


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Jan 25, 2011 5:57 pm   

Joined: Tue Jan 25, 2011 5:52 pm
Posts: 1
Hello... I have a request for a very simple bash script (I imagine). The problem is, I've never touched bash scripting in my life, so here is my psuedocode of sorts...

All I actually want to do is ssh into a list of servers (asynchronously), and do a kldstat | grep -c abc123. This will give me either a 0 or 1 if the module is/isn't loaded. For servers where the module IS loaded (count 1), I want it to write into a text file (on the server I'm running the script from ) the hostname. If the module isn't loaded (count 0 ), I want to write it into a different file on the server I'm running the script from.

#Run from HomeServer
#Grab list of servers
for server in $(cat something)&

#SSH to servers
ssh -o StrictHostKeyChecking=no $server

#Set Variable1 to the output of kldstat | grep -c abc123
variable1 = kdlstat | grep -c abc123

#Evaluate Variable1
if [variable1 = 0]
#Write to local file on HomeServer the servers hostname
hostname ; >> no-abc123.txt

#Evaluate Variable1
if [variable1 = 1]
#Write to local file on HomeServer the servers hostname
hostname ; >> abc123


Top
 Profile  
 PostPosted: Tue Jan 25, 2011 10:26 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 532
Hello,

you should start on more simple things, like detail each action of the pseudo code, and make it work; for example, first try to get the content of the anything file printed on your screen, in a way that fit your needs.

think, and talk about
local_host : the machine you're physically at
distant_host : the machine you're connected to.


Top
 Profile  
 PostPosted: Wed Feb 09, 2011 4:04 pm   

Joined: Thu Sep 16, 2010 3:57 am
Posts: 11
Hi :)
look at this topic viewtopic.php?f=8&t=1297
maybe it's helps

Code:
onall -u login -y -p -o $HOME/log.txt -f list_of_machines.txt 'kldstat | grep -c abc123'


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP