blob: f6ddf4fa1c46b748f043024a5f69239575cabf4c [file] [log] [blame]
{
"classLoaderSharing" : "workflow",
"script" : "if (command == void || command.equals(\"\")) {\n\tthrow new RuntimeException(\"The 'command' port cannot be null.\");\n}\nProcess proc = null;\nRuntime rt = Runtime.getRuntime();\n\nString osName = System.getProperty(\"os.name\");\nString[] cmdArray = null;\nif (osName.contains(\"Windows\")) {\n\tcmdArray = new String[] { \"cmd.exe\", \"/c\", command };\n} else {// TODO: investigate if this will work in Linux and OSX\n\tcmdArray = new String[] { command };\n}\n\n// concatenate the arrays\nif ((args == void) || (args == null)) {\n\targs = new ArrayList();\n}\n\nint argSize = cmdArray.length + args.size();\nArrayList appArray = new ArrayList(argSize);\nfor (int i = 0; i < cmdArray.length; i++) {\n\tappArray.add(cmdArray[i]);\n}\n\nfor (int i = 0; i < args.size(); i++) {\n\tappArray.add(args.get(i));\n}\n\nString[] applist = new String[argSize];\nappArray.toArray(applist);\nproc = rt.exec(applist);\n\n// Get the input stream and read from it\nInputStream in = proc.getInputStream();\n\nint c;\nStringBuffer sb = new StringBuffer();\nwhile ((c = in.read()) != -1) {\n\tsb.append((char) c);\n}\nin.close();\nresult = sb.toString();\n \n",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.io.LocalCommand",
"inputPorts" : [ {
"name" : "command",
"depth" : 0,
"type" : "String"
}, {
"name" : "args",
"depth" : 1,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "result",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}