Simplified a bit.
[xremote.git] / README.md
1
2 # Introduction #
3
4 This is a very simple bash script to run scripts on a remote machine
5 accessible by ssh, send required files, and get back result files
6 transparently.
7
8 It creates a temporary directory in /tmp/ on the remote host and runs
9 everything in it.
10
11 I use it mostly to launch heavy training with PyTorch on a PC at home.
12
13 # Example #
14
15 With
16
17 ```
18 xremote.sh ./example.py
19 ```
20
21 where [`example.py`](https://fleuret.org/git-extract/xremote/example.py) is the file given with `xremote.sh`:
22
23
24 ```
25 #!/usr/bin/env python
26
27 # @XREMOTE_HOST: elk
28 # @XREMOTE_EXEC: python3
29 # @XREMOTE_GET: *.txt
30 # @XREMOTE_SEND: *.py
31 # @XREMOTE_PRE: ls -lt > files.txt
32
33 print('I am being executed!')
34
35 file = open('result.txt', 'w')
36 file.write('This is a text.\n')
37 file.close()
38 ```
39
40 `xremote.sh` will:
41
42  1. create a temporary directory on the remote host 'elk'
43  2. copy there the file example.py,
44  3. copy there files from the local dir with the .py extension,
45  4. list all files on the remote side into the file files.txt,
46  5. execute example.py on the remote side with python3,
47  6. get back all the files with a .txt extension,
48  7. delete the working directory on the remote side.