We help IT Professionals succeed at work.

Linux Script

134 Views
Last Modified: 2017-04-18
Hello Folks,

I have a script *.sh That I like to install to few machines (IPs Address), is there anyway anybody can help me write script to do multiples at the same time ?

By the way I'm currently using centos x64

I'd appreciate it and thanks for looking
Comment
Watch Question

arnoldEE Topic Advisor, IT Consultant
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Please clarify what you are looking to do?
Scp in a script can be used to copy data across.
Depending on how many systems you manage, puppet might be something to consider with subversion as the change repository.

Centrally pushing, you would need the ssh keys (ahthorized_keys)

Author

Commented:
let me give you a an rough example idea, and tell me if is possible,

PCS=(IPS.txt [About 30 systems)
executable.sh

for /f %%a in (IPS.TXT) Do (
   copy executable.sh %%a\root\downloads\
   %%a\root\downloads\ ./executable.sh
   del %%a\executable.sh
 )
:end

I wish this would it have been a windows platform
arnoldEE Topic Advisor, IT Consultant
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
xcopy the issue is the destination is it a share or an administrative share?

Your notation seems that you are coming from a windows environment.
/root/downloads is this some kind of share?
you can not do it that way.

Author

Commented:
For the copy we could use a destination share or even a shared folder from Windows, If necessary...

With the example I do agree is a very vague, but it was as much as the idea that I could come up with, But we could follow any folder you propose...

And yes my background is Windows Batch, Psexec, or VBScript... I wish this was the case...
arnoldEE Topic Advisor, IT Consultant
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
the same process exists on linux using scp as the secure copy agent which goes in the form
scp localfile user@remote:/path/towherethe/fileshouldbe
this will prompt for password of user and user must be able to write into the directory used.
This is why the suggestion of ssh keys .....

Do these systems have a common NFS share each has access to?

cat IPS.txt | while read a; do
echo "copying to server: $a"
scp executable.sh user@$a:/root/downloads
echo "Exit status of transfer: $?"
done

Author

Commented:
Yes, I could create a SAMBA share, for all to connect to
arnoldEE Topic Advisor, IT Consultant
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You seem to be missing..
How often are you doing this, what does the script do?
Any share samba or NFS would require that you setup on the individual systems to monitor this share and act when a give each is looking for is present.......

Ssh user@remore 'execute a command' the result are sent back...
There are software as mentioned such as puppet that provides a means for central management of configs, there are commercial .......


You may wish to outline the end result that you are trying to achieve and receive options versus your current request which might be the wrong approach for  your situation.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
arnoldEE Topic Advisor, IT Consultant
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
This was one of the suggestions provided. Unlike windows in an AD environment, Linux systems do not have admin shares nor do they trust users from remote systems connecting in. The only way user@system1 is trusted to connect on systemB is through ssh-keys where the public key of user on system1 is added to user@systemb's .ssh/authorized_keys file.
And that often requires the user to provide the passphrase to the private key on system1.

Using ssh-keys you could setup a hub-spoke or two centralized systems that can connect to the others as a specific user.

There are times a question one asks because that is the approach they think will work, might be the wrong question because there are better way to achieve the result...

In this case it is unclear what the script is supposed to do with the request deals only on how to get a script onto other systems.

SNMP Is a service that can facilitate polling, system function, data extraction..monitoring...

Author

Commented:
issue has been resolved

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.