r3 - 01 Apr 2008 - 13:53:57 - StianSoilandYou are here: myGrid wiki >  Mygrid Web  > TavernaWorkbench > TavernaFaq > FaqCmdLine

How do I use the Execute_cmd_line_app tool?

Note that 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 cmd_line app, found under Local Java widgets -> io - 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's 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 (ie. you don't have to read any files produced), then you create the processor like this:

Right click on Execute cmd-line app and select Add to model. Right click on the input cmd to Set default value and fill in /usr/bin/perl (replace with the location of your perl).

If you need only one argument, you can right click on the input args and use Set default value. Note that this argument will be passed in as if it was quoted on the command line, if you try for instance cp as cmd 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 the list of arguments. We can use a String list union worker for this since we only need two arguments, under Local Java widgets -> Text, again right click and add. Connect the union output of the list union to the args input of the script. Rename the processors to for example Blah and Blah_args. For list1 on Blah_args set the default value to /home/stain/src/blah.pl - for list2 set the default value to gene. Note that this works because Taverna will wrap the two list1 and list2 arguments as two lists with one value each, output the union of the two lists, ie. 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 don't 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 currently 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 is:

#!/usr/bin/perl
print "Hello there\n";
print $ARGV[0];
print "\n";

then running the workflow should yield a single output from Blah of:

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 won't be in /home/stain/src/blah.pl and if you are on Windows or an archaic Unix, your Perl won't be in /usr/bin/perl. In addition, if your script does something useful and uses libraries from CPAN then those libraries might not have be installed. This is the main reason why we don't 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 colleague to use it. As a scientific description of your workflow it doesn't include what happens inside blah.pl.

If you are just doing regular expressions we recommend exploring the available shim services under "Local services" - possibly writing a little beanshell snippet using the Beanshell processor if nothing suitable exists.

If your Perl script is doing something useful, we recommend you expose it as a service so others also can benefit.

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
 
Powered by myGrid wiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding myGrid wiki? Send feedback