[kepler-dev] [Bug 3207] - consolidate command line execution actors

bugzilla-daemon@ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Fri Apr 18 08:58:05 PDT 2008


http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3207





------- Comment #7 from cxh at eecs.berkeley.edu  2008-04-18 08:58 -------
I'm part way through the merge, and had two questions.

1) The new version of the actor always uses adds prepends cmd or
sh to the command line.
This method was added:
   /** Get the command list arguments for exec. */
    protected List<String> _getCommandList() {
        List<String> retval = new LinkedList<String>();

        String osName = System.getProperty("os.name");
        if (osName.equals("Windows NT") || osName.equals("Windows XP")
                || osName.equals("Windows 2000")) {
            retval.add("cmd.exe");
            retval.add("/C");
        } else if (osName.equals("Windows 95")) {
            retval.add("command.com");
            retval.add("/C");
        } else {
            retval.add("/bin/sh");
            retval.add("-c");
        }
        return retval;
    }

which is later called with:
          List<String> commandList = getCommandList();
          commandList.add(((StringToken) command.getToken()).stringValue());

My question here is: do we always want to preface the command with sh
or cmd?  This is definitely a change from the old Ptolemy version, and
worthy of discussion.  At a minimum, we should update the class comment.
My concern here is that we are breaking backward compatibility.
What do we gain by invoking bash?
This change does cause $PTII/ptolemy/actor/lib/test/auto/ExecEnvironment.java
to fail because that test uses the "env" command, which is not found
for me under Windows XP with cygwin when Exec uses sh.

For example, if I invoke sh from a cmd window, then the path does not
include /usr/bin:
C:\cxh\ptII>c:/cygwin/bin/sh -i
sh-3.2$ env
sh: env: command not found
sh-3.2$ echo $PATH
/cygdrive/c/Program Files/Java/jdk1.6.0_05/bin:/cygdrive/c/matlab701/bin/win32

This is with a fairly new installation of cygwin.

However, if Exec does not invoke sh, then the test passes, I think
because the path is properly set from the parent process.

Here I propose that either we remove the code that adds the sh or cmd
or else make it optional.  I'd consider keeping it non-optional, but would
like some discussion.


2) The second problem is that the new version does not properly handle
command lines that use double quotes to separate command line arguments.

This text was removed:
            // tokenizeForExec() handles substrings that start and end
            // with a double quote so the substring is considered to            
            // be a single token and are returned as a single array
            // element.
            String[] commandArray = StringUtilities
                    .tokenizeForExec(((StringToken) command.getToken())
                            .stringValue());

As a result, $PTII/ptolemy/actor/lib/test/auto/Exec.xml fails because
it invokes the command 
echo "Hello World"

I think this should be fairly easy to fix in the new version.


A third issue is that I should merge this actor with code in 
ptolemy.util.StreamExec.  However, I think it would be best to wait on this
change.


More information about the Kepler-dev mailing list