Friday, January 09, 2009

Script to push any script to all the servers in a unix environment

It is always helpful for any dba to have a script that can push any regularly used scripts to all the servers. In my case, we had a centralized server where have all the scripts and there was authentication setup, either remsh or ssh. The script below checks if 1) it can ping the server, 2) if it can ping it, can it ssh? 3) If it cannot ssh, can it remsh?

I run this script from Sun OS. If you run it from any other OS like linux, the ping command would be different. Change it accordingly.

Operating System : SunOS


===================== Script start ==================================

cat push_script.sh

#!/usr/bin/ksh

list=`cat /tmp/complete_server_list.lst`

for i in $list

do

ping -s $i 64 1 |grep -w "0% packet loss" # Check if we can ping the server

if [[ $? -eq 0 ]];then

ssh -o BatchMode=yes $i /bin/true # Check if ssh is enabled, if not use remsh/rcp

if [[ $? -eq 0 ]];then

scp -p /tmp/test_script $i:/tmp/test_script

else

rcp -p /tmp/test_script $i:/tmp/test_script

fi

else

echo "${i}" >> /tmp/cantping.lst

fi

done


===================== Script End==================================

26 comments:

Anonymous said...

Truly when someone doesn't know then its up to other visitors that they will assist, so here it occurs.

Feel free to visit my blog post: grand cayman islands vacation

Anonymous said...

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a
comment is added I get three emails with the same comment.

Is there any way you can remove me from that service?
Thanks!

Visit my website ... Dedicated Hosting Linux

Anonymous said...

I am genuinely happy to read this blog posts which contains tons of useful data, thanks for providing such
data.

my blog ... billige schuhe kaufen
Also see my web site > shoe online shop

Anonymous said...

I visit day-to-day some websites and information sites to read
articles, but this weblog gives feature based articles.



Stop by my webpage; home equity credit

Anonymous said...

Can you tell us more about this? I'd want to find out more details.

My web blog: clickbank alternatives

Anonymous said...

Keep on working, great job!

Feel free to surf to my site; student loans rates

Anonymous said...

Amazing! This blog looks exactly like my old one!
It's on a totally different topic but it has pretty much the same page layout and design. Outstanding choice of colors!

My blog post ... umschuldung ohne schufa

Anonymous said...

Greetings! I know this is kinda off topic
however , I'd figured I'd ask. Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
My blog covers a lot of the same subjects as yours and I feel we
could greatly benefit from each other. If you might be
interested feel free to shoot me an e-mail. I look forward to
hearing from you! Wonderful blog by the way!

Feel free to visit my web blog; beiträge krankenkassen

Anonymous said...

I think this is one of the most vital information for me.
And i am glad reading your article. But wanna remark on some general things, The web site style is great,
the articles is really excellent : D. Good job, cheers

My web blog kosten gesetzliche krankenversicherung

Anonymous said...

Link exchange is nothing else but it is only placing
the other person's webpage link on your page at appropriate place and other person will also do similar for you.

Here is my webpage; best website host

Anonymous said...

I really like it when people come together and share ideas.
Great blog, stick with it!

My homepage holidays all inclusive
My page > bahama vacations all inclusive

Anonymous said...

Thank you for some other informative website.
Where else may I am getting that kind of info written in such an ideal way?
I've a venture that I am simply now running on, and I have been on the look out for such information.

Take a look at my page best home equity loan rates
My site - home loans equity

Anonymous said...

Great post. I was checking constantly this blog and
I'm impressed! Very useful information particularly the last part :) I care for such information a lot. I was seeking this certain information for a very long time. Thank you and best of luck.

Take a look at my website Gesetzliche Krankenversicherung Preisvergleich

Anonymous said...

Hello to every one, the contents existing at this website are truly amazing for people experience, well,
keep up the nice work fellows.

My web blog - krankengeld versicherung vergleich
My web page - was ist krankenversicherung

Anonymous said...

Hi! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing
several weeks of hard work due to no back up. Do you have any solutions to protect against hackers?



My blog free linux hosting

Anonymous said...

I just like the valuable info you supply on your articles.
I will bookmark your weblog and test again right here
frequently. I'm slightly sure I will be told a lot of new stuff proper right here! Good luck for the next!

my web page ... private oder gesetzliche krankenversicherung
my webpage :: vergleich pkv online

Anonymous said...

Wow, fantastic blog layout! How long have you been running a blog for?

you made blogging glance easy. The full look of your web site is excellent, as well as
the content!

Feel free to surf to my blog post: entrepreneur opportunities

Anonymous said...

Hello There. I found your blog using msn. This
is a very well written article. I'll make sure to bookmark it and return to read more of your useful info. Thanks for the post. I will definitely return.

My web page - free web hosting php
My website :: best hosting company uk

Anonymous said...

If you are going for most excellent contents like me, just pay a visit this
site every day because it offers feature contents, thanks

Here is my weblog pkv kinder
My site - private krankenversicherung beitragsbemessungsgrenze 2011

Anonymous said...

When I originally commented I clicked the "Notify me when new comments are added" checkbox
and now each time a comment is added I get four e-mails
with the same comment. Is there any way you can remove
me from that service? Cheers!

Here is my web blog :: blitzkredit ohne schufa

Anonymous said...

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added
I get four e-mails with the same comment. Is there any way you can remove me from that service?
Cheers!

Also visit my blog post :: blitzkredit ohne schufa
My webpage - sofortkredit für arbeitslose

Anonymous said...

It's actually very complex in this full of activity life to listen news on Television, therefore I only use world wide web for that reason, and get the latest information.

Check out my weblog; napapijri online outlet

Anonymous said...

With havin so much written content do you ever run into any issues of plagorism or copyright violation?
My blog has a lot of exclusive content I've either authored myself or outsourced but it appears a lot of it is popping it up all over the internet without my authorization. Do you know any ways to help protect against content from being ripped off? I'd certainly
appreciate it.

My homepage - bad credit financing

Anonymous said...

Аah I get it now! І thought you meant thiѕ to be an oρtional cгazy aԁdіtiοn.


Havе a look at my page fast unsecured cash loan

Anonymous said...

thank you for the aid!

Also visit my website ... guenstig urlaub angebote

Anonymous said...

smokeless cigarettes, e cigarette, electronic cigarette, e cigarette reviews, e cigarette, smokeless cigarettes