2

Possible Duplicate:
Execute arbitrary python code remotely - can it be done?

I wrote a memory usage check function and it runs fine on one server (say 10.100.110.10).
But I need to run the same script remotely on 10.100.110.11 from 10.100.110.10. I can ssh to 10.100.110.11 from 10.100.110.10. Is there any way to implement that using python built in modules?

I can't use any new modules like Paramico and Unix command

ssh -n user@10.100.110.11 "df -m"

works fine. If it is not possible, how can I ssh to 10.100.110.11 using a built in Python module?

Community
  • 1
  • 1
ffran09
  • 887
  • 7
  • 9
  • 1
    http://stackoverflow.com/questions/946946/how-to-execute-a-process-remotely-using-python –  Nov 07 '12 at 08:50
  • that might have what you're looking for –  Nov 07 '12 at 08:51
  • have you considered using some standard tool for system monitoring instead? (e.g., [snm](http://snm.sourceforge.net/), [munin](http://munin-monitoring.org/)) – moooeeeep Nov 07 '12 at 08:57
  • Any reason you can't use `paramiko` (or better, `fabric`) - why does the constraint exist that's effectively "you're not allowed to use the right tools for this... work around it somehow..."? – Jon Clements Nov 07 '12 at 09:06

1 Answers1

0

You cannot remotely run Python code if you're not accessing the Python interpreter on the other side. You could sent the code the the Python's interpreter standard input, but you still have to send the code.

The other solution would be to make your code remote-compatible, and replace all systems calls by their equivalents over SSH (using Paramiko for example).

pistache
  • 5,782
  • 1
  • 29
  • 50
  • @smaccoun i had seen and tried the solution given in the link you provided. it did not work for me. – ffran09 Nov 15 '12 at 23:54
  • @moooeeeep i can not use any extra tools as I already have a running program for the same and new tool installation will not abe allowed unless I prove that it would work – ffran09 Nov 15 '12 at 23:56
  • @Jon Clements: i can not use any extra tools as I already have a running program for the same and new tool installation will not abe allowed unless I prove that it would work – ffran09 Nov 15 '12 at 23:57
  • i do have python interpreter on the remote server. Anyways I did a work around for the time bieng. – ffran09 Nov 15 '12 at 23:58
  • @smaccoun the error I was getting when I tried that link was "test.py: command not found". I when I pass a command that is executable in the other server, it gives output. So I guess I need to deploy the script in the remote server for it to work – ffran09 Nov 16 '12 at 00:09