views:

124

answers:

4

I would like to automate the creation of symbolic links on my laptops from a simple Rails app running on a remote server. I would need to be able to run kernel tasks on the laptop from anywhere. Is this even possible to do?

A: 

If it's only your laptop and no other client, then you can make the server ssh to your laptop and do whatever it needs. In general, no, it's not possible for a HTTP server to do anything on the client machine.

Lukáš Lalinský
+1  A: 

You could do it by mounting the file system using Fuse. It's quite a neat little thing, in my opinion.

Find Fuse here

Edit: Changed the link to point to FuseFs, which is fuse with Ruby bindings, which is what you'll need if you're using Ruby.

Banang
+2  A: 

Fetch a script from remote and execute it

Your server could create a Shell or Ruby script which is targeted to be executed on your laptop. Your laptop now needs to regular check for this script and execute it. The advantages of this are:

  • This works not only for your laptop but for any other machine which checks for the script.
  • You don't need any other transport than http
  • The server does not need to know of the client in advance
  • This works for any other task than creating symbolic links without change on the client side.

The client side could be as simple as:

wget -O - "url" | ruby -

or

wget -O - "url" | sh -

Generate a list of symbolic links on your server

Your server could create a list of the needed symbolic links. On your client machine you would need a program which regular parses this list and creates the symbolic links. The advantages are:

  • You don't need to trust the server
  • Your server can not do rm -rf / by accident
  • You don't need any other transport than http
  • This works not only for your laptop but for any other machine which checks for the list.

The client side could be as simple as

wget -O - "url" | ruby -r yaml -e "YAML.load(STDIN).each { |a, b| \`ln -s \"#{a}\" \"#{b}\" \` }"
johannes
A: 

You can use puppet which is ruby based.

bhups