how to run a shell script from remote server to local server.
Hi,
I am using Solaris. SunOS <hostname> 5.10 Generic_144488-17 sun4v sparc SUNW,Sun-Blade-T6340 We are preparing to keep all the scripts on one particular remote server. And we have to use those scripts from there to run on local servers. How will I achieve this? I searched this below mentioned link from google: http://unix.stackexchange.com/questi...-local-machine In this forum they were talking about sshing the server and copying the script from remote server to local server. But is there any other way to achieve this? Please share some ideas! |
Perhaps you can download the script core with Furl and Pipe to bash. Something like this...
Curl http://remoteurl/script.sh | bash |
I suppose the simplest solution would be to have the scripts on a network filesystem , mount that on local server(s)
I take that back, bypper's is simpler |
We don't have to download the script from remote server. Is there any other way?
|
I have this code mentioned below:
Code:
#!/bin/sh This is the code above and what modification can be done in this code so that I can run this script from remote server to local server? I have an idea that using ssh we can do but how to do that, what modification will be done in this script for that, that I'm not getting. |
Quote:
Code:
mount.nfs etc /mnt/remote Code:
echo "cat /path/to/file.sh" | ssh somewhere Code:
bash <(echo "cat /path/to/file.sh" | ssh ...) Code:
#!/bin/bash Sorry the proper ssh command should actually be: Code:
ssh remote-server -- cat /path/to/file.sh Code:
bash <(exec ssh remote-server -- cat /path/to/file.sh) Code:
bash <(exec ssh remote-server -- cat /path/to/file.sh 2>/dev/null) |
just wanted to clarify "downloading"
Whatever you do the local server must "download" the script bypper's example uses curl, by default curl "outputs" to stdout which is being piped to bash the script is not saved to the filesystem. Anyway... Code:
current-das=~/current-das are they on the local machines, or on the remote server? if on the remote, then network filesystem is what you want/need. But you will want to get those logs "unique" to each local machine, since you are greping a tail ( what if two "clients" were running the script at same time ) assuming they are "local" Is the "no download" requirement for version control? If so you could use rsync to keep the local copies in sync with 'master' script but even then you would still need to exercise version control on ~/current-das... ( which could also be achieved with rsync ) |
Hi konsolebox,
Quote:
And all the other methods suggested by you will definitely work. How about putting ssh -T das@<IP_address> <<EOI and end of the script EOI. Please make me correct if I'm wrong. |
Hi Firerat,
Quote:
No download requirement for version control. |
Quote:
You are going to need something on each "local" machine to get the script anyway.. So why not just have the script local? I don't mind :) It is just I know I must be missing something. |
Quote:
Quote:
|
Quote:
Code:
ssh server -- cat /path/to/file Code:
#!/bin/bash Code:
#!/bin/bash Code:
#!/bin/bash |
Hi,
My seniors suggested me to make some modification in the script and to make it more modular using function. So, I come with this solution and please suggest me if it is correct. I used ssh also in this script to ssh the remote server and user have to give username and IP address as the parameters while running the script. And as you can see I used if-else condition in every function. I think that condition will run on local server and will give me error. So, how will I check the condition after starting the service and saving it in log file on local server. Or I have made it correct? Please verify. Also I want to know that how will I call the functions mentioned in the script. Code:
#!/bin/sh |
For starters I would give a form like this:
Code:
#!/bin/sh And about 1>&2 >> /logs/log.out, does that intend to send a message to stderr but have a copy of it to /logs/log.out? I would suggest creating functions that would do that as well like log_message() and log_error(): Code:
log_message() { Btw, you haven't called any function yet in the part after the user presses y. |
Quote:
Quote:
And what is the main in the last line in the above modified script by you? Code:
if [ "$RESP" = "y" ] || [ "$RESP" = "Y" ]; then And where do I have to include these log_message and log_error function? In the same script or in other script? And I found on the google and got some more modification by me so far. :) Please take a look! Code:
#!/bin/sh |
All times are GMT -5. The time now is 08:49 PM. |