-4

I have the following situation. I want to write python code in my Laptop that will take more than 24 hours to run.I am using UBUNTU 12.04 lts.

Is it possible so that I write python code in my laptop, automatically send it to some remote desktop, run there and send the output result to my laptop when done? one way suggested to me is to use openssh.

But I want to do this in the following way----

  1. Write and Debug Python Code in my laptop.(Solved)
  2. email the code as attachment to ****@gmail.com(Solved)
  3. Other python program in the desktop will automatically download and run the source code(Unsolved)
  4. and email the output file back to my gmail id.(Solved)

what is the python code to download the attachment from the latest email from a specific gmail folder?

Square
  • 3
  • 1
  • 3
  • If you're application/simulation takes over 24 hours a compiled language might be a better choice than python. – Chris Seymour Dec 19 '13 at 10:45
  • It might not Be because of the massiveness of the programm, for all we know he is collecting data over a 24 hour timespan. Which exactly points out what is wrong with this question btw... see [How to ask?](http://stackoverflow.com/questions/how-to-ask) – Kraay89 Dec 19 '13 at 10:47
  • 1
    Also have a look at this related question: http://stackoverflow.com/q/536370/1025391 – moooeeeep Dec 19 '13 at 10:49

2 Answers2

1

If your remote system is windows, a good option would be to use PsExec from SysInternals.

Ex. If your script is long_running.py a typical usage would be

PsExec \\remote-server -c long_running.py

If your remote system is *nix, and your local system is Windows, you can use ssh for remote execution via Plink (part of PuTTY).

plink remote-server@user -m long_running.py

Finally if both remote and local machine are *nix systems, you can simply use ssh

ssh remote-server@user 'bash -s' < long_running.py

Note This is just some possible options, but the idea is remote execution is possible either via ssh or a similar option (like PsExec) for Windows

Abhijit
  • 62,056
  • 18
  • 131
  • 204
0

If both systems are running *nix, you can easily do all your dev work and debugging locally, while still executing remotely:

One time set up:

  1. Mount a folder from the remote box locally
  2. On your laptop, save your project/script to that (now local) folder, or set the mounted folder as your project's save path in your IDE.

Publishing:

  1. Do work
  2. Click the save button

Executing:

  1. SSH into the remote box and open a new screen
  2. Navigate to the folder you'd previously mounted, and run your script.
  3. You can then safely detach and close ssh if necessary (ctrl+a d), and re-attach later:
    3a. screen -ls (to find the screen name)
    3b. screen -x screen_name

The advantage of this solution is that if you've got an ongoing project requiring frequent edits/changes, you can do all your dev work/debugging locally, and the only work required to "publish" is clicking the save button, starting the screen, and running.

Sintrinsic
  • 86
  • 5