How do I use the Execute Command Line service from a workflow?

Generally, we discourage the use of local tools in this way as your workflow will be highly specialised for your machine and setup. The Execute Command Line App, found under Available Services > Local Services > io in Taverna 2.x and Available Processors > Local Services > Local Java Widgets > io in Taverna 1.7.2, will let you execute any command on the local system.

You will notice it has two inputs: command and args. This is the command to execute and its arguments, as a list. Let us assume you want to run a Perl script that you have already written. Say your Perl script is in /home/stain/src/blah.pl and it requires an argument gene, and it outputs useful stuff on standard out (i.e. you do not have to read any files produced). Then you do the following.

Add Execute Command Line App service/processor to your workflow. Set the constant (default) value of the input port command to /usr/bin/perl (replace with the location of Perl on your system).

If you need only one argument, you can right click on the input port args and set it as the constant (default) value for this port. Note that this argument will be passed in as if it was quoted on the command line. If you try for instance cp as command and file1 file2 as args, it would mean to copy the file named "file1 file2", including the space.

Since we need two arguments, we have to construct a list of arguments. We can use a String List Union local service/widget for this since we only need two arguments, found under Available Services > Local Services > text in Taverna 2.x and Available Processors > Local Services > Local Java Widgets > text in Taverna 1.7.2. Add this service/processor to the workflow. Connect the union output of the list union to the args input of the script. Rename the services to, for example, Blah and Blah_args. Set the constant (default) value for list1 input port on Blah_args to “/home/stain/src/blah.pl”. Set the constant (default) value of list2 input port of Blah_args to “gene”. Note that this will work because Taverna will wrap the list1 and list2 arguments as two lists with one value each, output the union of the two lists, i.e. a list of two strings. (There are other ways to construct lists. One way would be to get it as a workflow input, but we assume here you do not want to have to specify the Perl script path every time you run the workflow.)

If you need an empty list (no arguments), or more than two arguments, unfortunately you would need to do this using a Beanshell script. For instance:

List args = new ArrayList();

args.add(”/home/stain/src/blah.pl”);
args.add(”gene”);

Say /home/stain/src/blah.pl contains:

#!/usr/bin/perl
print “Hello there\n”;
print $ARGV[0];
print ā€œ\nā€;

Then running the workflow should yield a single output from service Blah as:

Hello there
gene

This would be the same as on the command line:

: stain@mira ~/; /usr/bin/perl /home/stain/src/blah.pl gene
Hello there
gene

You might want to split the output by line so that you can get a list of lines, depending on what you want to do with the output.

Now, as you will probably find out, your script will not be in /home/stain/src/blah.pl, and if you are on Windows or some versions of Unix, your Perl will not be in /usr/bin/perl. In addition, if your script uses libraries from CPAN then those libraries might not have been installed. This is the main reason why we do not recommend this solution. Your workflow will not be portable and sharable. It will not be easy to run this workflow in a Remote Workflow Execution Service, and it will be difficult for your colleagues to use it. As for a scientific description of your workflow, it does not include what happens inside blah.pl script.

If you are just doing regular expressions, we recommend exploring the available Local “shim” services/widgets. Or writing a little Beanshell service if nothing suitable exists.

We would recommend you to expose your Perl script as a service so others can benefit as well.