5 title: "Running external programs"
9 h1. Running external programs
11 This tutorial demonstrates how to use Crunch to run an external program by writting a wrapper using the Python SDK.
13 *This tutorial assumes that you are "logged into an Arvados VM instance":{{site.baseurl}}/user/getting_started/ssh-access.html#login, and have a "working environment.":{{site.baseurl}}/user/getting_started/check-environment.html*
15 In this tutorial, you will use the external program @md5sum@ to compute hashes instead of the built-in Python library used in earlier tutorials.
17 Start by entering the @crunch_scripts@ directory of your git repository:
20 <pre><code>~$ <span class="userinput">cd <b>you</b>/crunch_scripts</span>
24 Next, using @nano@ or your favorite Unix text editor, create a new file called @run-md5sum.py@ in the @crunch_scripts@ directory.
26 notextile. <pre>~/<b>you</b>/crunch_scripts$ <code class="userinput">nano run-md5sum.py</code></pre>
28 Add the following code to use the @md5sum@ program to compute the hash of each file in a collection:
30 <pre><code class="userinput">{% include 'run_md5sum_py' %}</code></pre>
32 Make the file executable:
34 notextile. <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">chmod +x run-md5sum.py</span></code></pre>
36 Next, add the file to @git@ staging, commit and push:
39 <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">git add run-md5sum.py</span>
40 ~/<b>you</b>/crunch_scripts$ <span class="userinput">git commit -m"run external md5sum program"</span>
41 ~/<b>you</b>/crunch_scripts$ <span class="userinput">git push origin master</span>
45 You should now be able to run your new script using Crunch, with "script" referring to our new "run-md5sum.py" script.
48 <pre><code>~/<b>you</b>/crunch_scripts$ <span class="userinput">cat >~/the_job <<EOF
50 "script": "run-md5sum.py",
51 "script_version": "you:master",
54 "input": "c1bad4b39ca5a924e481008009d94e32+210"
58 ~/<b>you</b>/crunch_scripts$ <span class="userinput">arv job create --job "$(cat the_job)"</span>
61 "uuid":"qr1hi-xxxxx-xxxxxxxxxxxxxxx"
64 ~/<b>you</b>/crunch_scripts$ <span class="userinput">arv job get --uuid qr1hi-xxxxx-xxxxxxxxxxxxxxx</span>
67 "output":"4d164b1658c261b9afc6b479130016a3+54",