Link to home
Start Free TrialLog in
Avatar of ivan rosa
ivan rosaFlag for United States of America

asked on

Linux Script

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
Avatar of arnold
arnold
Flag of United States of America image

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)
Avatar of ivan rosa

ASKER

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
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.
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...
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
Yes, I could create a SAMBA share, for all to connect to
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.
ASKER CERTIFIED SOLUTION
Avatar of ivan rosa
ivan rosa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...
issue has been resolved