Host Script in the Cloud


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Host Script in the Cloud
# 1  
Old 10-31-2014
Host Script in the Cloud

OSX

Is there a way to host a script on a server? Specifically, the end user would pop in a terminal command or script that fetches text (a formatted script) from a server and runs that code on the local system.

I want to do this because I have a script that is constantly evolving and it would be nice to edit a source file on a server for updates without having to push out a new script every time.

I think it's worth mentioning this would be done behind a firewall.
# 2  
Old 11-02-2014
Yes you can use wget to fetch the script from a server to the local system as long as your firewall will allow the local system to http:// (port 80) browse to the server in question.

Code:
wget http://yourserver.com/path/to/your/script.sh
if [[ -f script.sh ]] && [[ $(md5sum < /usr/local/bin/yourscript.sh) != $(md5sum < script.sh ]]
then
    cp /usr/local/bin/yourscript.sh /usr/local/bin/yourscript.old
    mv script.sh /usr/local/bin/yourscript.sh 
else
    rm -f script.sh
fi

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 11-02-2014
How about you pass an 'execution' script to the users, which does similar things like Chubler_XL suggested.
But basicly, it will just download your real script and execute it.
This User Gave Thanks to sea For This Post:
# 4  
Old 11-02-2014
Yes depending on how frequently you expect it to change. One could use a daily/hourly cron job to check for updates, or always fetch it and execute as you go.

I would be careful if the script is executed as root as it would be very easy for someone to attach and insert their own script into your system. Perhaps using https:// with a proper certificate would be wise.
This User Gave Thanks to Chubler_XL For This Post:
# 5  
Old 11-02-2014
This said, you could also package it according to your package manager.

As in, TUI (Text User Interface) is actualy a bash based project, and since my linux is fedora, i have it packated as an rpm.
But regardless if its a script or not, if it needs updating on a frequent basis, a package might be more apropriate.

hth
This User Gave Thanks to sea For This Post:
# 6  
Old 11-03-2014
Quote:
Originally Posted by Chubler_XL
Yes you can use wget to fetch the script from a server to the local system as long as your firewall will allow the local system to http:// (port 80) browse to the server in question.

Code:
wget http://yourserver.com/path/to/your/script.sh
if [[ -f script.sh ]] && [[ $(md5sum < /usr/local/bin/yourscript.sh) != $(md5sum < script.sh ]]
then
    cp /usr/local/bin/yourscript.sh /usr/local/bin/yourscript.old
    mv script.sh /usr/local/bin/yourscript.sh 
else
    rm -f script.sh
fi

Thanks Sea and Chubler. So, wget would be cool but it would require everybody to procure wget, so I would like to stay within the normal scope of bash on OSX. I was thinking about using SSH and either a scp or rsync to grab the file.

With that being said. I was hoping to get your input on this:

Route 1: Distribute a script that simply ssh's into the server, pulls the script down to /tmp, executes, and removes from /tmp when finished.

Route 2: Distribute the up-to-date version of the script, use diff to check the local version with the server version, if there is a difference overwrite the local version with server version, execute.

Thoughts?
# 7  
Old 11-03-2014
Depending on the script complexity, a simple ssh user@host cat script.sh | sh might be sufficient.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWS Cloud EBS limit script!

Hi, I am trying to correct the following script to get total EBS usage from Amazon cloud. Can someone please help in correcting it. It appears that its not working properly. t=0; for i in `ec2-describe-volumes | grep VOLUME | grep standard | awk '{print $3}'`; do t=`expr $t + $i`; done;... (2 Replies)
Discussion started by: amar0000
2 Replies

2. Solaris

Need to recover/move diskgroup from failed host to another host

Hi All I am having VxVm on two Solaris hosts. host1 is using disk group dgHR. right now this server went down due to hardware fault. Not I need to import this dgHR into host2 server. Please let me know the procedure for the same. (1 Reply)
Discussion started by: amity
1 Replies

3. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

4. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

5. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

6. Virtualization and Cloud Computing

Event Cloud Computing - IBM Turning Data Centers Into ?Computing Cloud?

Tim Bass Thu, 15 Nov 2007 23:55:07 +0000 *I predict we may experience less*debates*on the use of the term “event cloud”*related to*CEP in the future, now that both IBM and Google* have made announcements about “cloud computing” and “computing cloud”, IBM Turning Data Centers Into ‘Computing... (0 Replies)
Discussion started by: Linux Bot
0 Replies

7. IP Networking

QNX host cannot ping SCO host, vice versa

The problem I am facing now is that the QNX host could not ping the SCO host and vice versa. They are in the same domain, ie, 172.20.3.xx. As I am very new to Unix, I guess I must have missed out some important steps. Pls help... Thanx alot (2 Replies)
Discussion started by: gavon
2 Replies
Login or Register to Ask a Question