From 9241850435948e2f3c91fbdf620acfecbf26c9b9 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 13 Jul 2017 21:11:01 +0200 Subject: [PATCH] Added a bit of documentation. --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ example.py | 13 +++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 README.md create mode 100755 example.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc0a2d1 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ + +# Introduction # + +This is a very simple bash script to run scripts on a remote machine +accessible by ssh, send required files, and get back result files +transparently. + +It creates a temporary files in /tmp/ on the remote host and run +everything in it. + +I use it mostly to launch heavy training with pytorch on a PC at home. + +# Example # + +With + +``` +xremote.sh ./example.py +``` + +where [`example.py`](https://fleuret.org/git-extract/xremote/example.py) is the file given with `xremote.sh`: + + +``` +#!/usr/bin/env python + +# @XREMOTE_HOST: elk +# @XREMOTE_EXEC: python3 +# @XREMOTE_GET: *.txt +# @XREMOTE_SEND: *.py +# @XREMOTE_PRE: ls -lt > files.txt + +print('I am being executed!') + +file = open('result.txt', 'w') +file.write('This is a text.\n') +file.close() +``` + +`xremote.sh` will: + + 1. create a temporary directory on the remote host 'elk' + 2. copy there the file example.py, + 3. copy there files from the local dir with the .py extension, + 4. list all files on the remote side into the file files.txt, + 5. execute example.p on the remote side, + 6. get back all the files with the .txt extension, + 7. delete the working directory on the remote side. diff --git a/example.py b/example.py new file mode 100755 index 0000000..d545018 --- /dev/null +++ b/example.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +# @XREMOTE_HOST: elk +# @XREMOTE_EXEC: python3 +# @XREMOTE_GET: *.txt +# @XREMOTE_SEND: *.py +# @XREMOTE_PRE: ls -lt > files.txt + +print('I am being executed!') + +file = open('result.txt', 'w') +file.write('This is a text.\n') +file.close() -- 2.39.5