[jira] Created: (EXEC-45) Error while executing a command like echo

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (EXEC-45) Error while executing a command like echo

Woonsan Ko (Jira)
Error while executing a command like echo
-----------------------------------------

                 Key: EXEC-45
                 URL: https://issues.apache.org/jira/browse/EXEC-45
             Project: Commons Exec
          Issue Type: Bug
    Affects Versions: 1.0.1
         Environment: OS: Windows XP SP3
            Reporter: varma
            Priority: Blocker



Hello,
After looking at the javaDoc for DefaultExecutor, I've tried a simple command the does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.

This is what I'm trying:
{code:title=CommandExec.java|borderStyle=solid}
public final void executeEcho()
{
      try
      {
         final CommandLine command = new CommandLine( "echo someValue" );
         command.addArgument( "> c:\test.txt" );

         final DefaultExecutor executor = new DefaultExecutor();
         final int value = executor.execute( command );
         System.out.println(value);
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
}
{code}

Exception being thrown:
{code:title=exception}
java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
        at testing.CommandExex.main(CommandExex.java:15)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 8 more
{code}

From DefaultExecutor's JavaDoc:
{code}
Executor exec = new DefaultExecutor();
CommandLine cl = new CommandLine("ls -l");
int exitvalue = exec.execute(cl);
{code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (EXEC-45) Error while executing a command like echo

Woonsan Ko (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-45?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

varma updated EXEC-45:
----------------------

       Priority: Major  (was: Blocker)
    Description:
Hello,
After looking at the javaDoc for DefaultExecutor, I've tried a simple command that does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.

This is what I'm trying:
{code:title=CommandExec.java|borderStyle=solid}
public final void executeEcho()
{
      try
      {
         final CommandLine command = new CommandLine( "echo someValue" );
         command.addArgument( "> c:\test.txt" );

         final DefaultExecutor executor = new DefaultExecutor();
         final int value = executor.execute( command );
         System.out.println(value);
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
}
{code}

Exception being thrown:
{code:title=exception}
java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
        at testing.CommandExex.main(CommandExex.java:15)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 8 more
{code}

From DefaultExecutor's JavaDoc:
{code}
Executor exec = new DefaultExecutor();
CommandLine cl = new CommandLine("ls -l");
int exitvalue = exec.execute(cl);
{code}

  was:

Hello,
After looking at the javaDoc for DefaultExecutor, I've tried a simple command the does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.

This is what I'm trying:
{code:title=CommandExec.java|borderStyle=solid}
public final void executeEcho()
{
      try
      {
         final CommandLine command = new CommandLine( "echo someValue" );
         command.addArgument( "> c:\test.txt" );

         final DefaultExecutor executor = new DefaultExecutor();
         final int value = executor.execute( command );
         System.out.println(value);
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
}
{code}

Exception being thrown:
{code:title=exception}
java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
        at testing.CommandExex.main(CommandExex.java:15)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 8 more
{code}

From DefaultExecutor's JavaDoc:
{code}
Executor exec = new DefaultExecutor();
CommandLine cl = new CommandLine("ls -l");
int exitvalue = exec.execute(cl);
{code}


> Error while executing a command like echo
> -----------------------------------------
>
>                 Key: EXEC-45
>                 URL: https://issues.apache.org/jira/browse/EXEC-45
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>         Environment: OS: Windows XP SP3
>            Reporter: varma
>
> Hello,
> After looking at the javaDoc for DefaultExecutor, I've tried a simple command that does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.
> This is what I'm trying:
> {code:title=CommandExec.java|borderStyle=solid}
> public final void executeEcho()
> {
>       try
>       {
>          final CommandLine command = new CommandLine( "echo someValue" );
>          command.addArgument( "> c:\test.txt" );
>          final DefaultExecutor executor = new DefaultExecutor();
>          final int value = executor.execute( command );
>          System.out.println(value);
>       }
>       catch(Exception e)
>       {
>          e.printStackTrace();
>       }
> }
> {code}
> Exception being thrown:
> {code:title=exception}
> java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessBuilder.start(Unknown Source)
> at java.lang.Runtime.exec(Unknown Source)
> at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
> at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
> at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
> at testing.CommandExex.main(CommandExex.java:15)
> Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessImpl.create(Native Method)
> at java.lang.ProcessImpl.<init>(Unknown Source)
> at java.lang.ProcessImpl.start(Unknown Source)
> ... 8 more
> {code}
> From DefaultExecutor's JavaDoc:
> {code}
> Executor exec = new DefaultExecutor();
> CommandLine cl = new CommandLine("ls -l");
> int exitvalue = exec.execute(cl);
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (EXEC-45) Error while executing a command like echo

Woonsan Ko (Jira)
In reply to this post by Woonsan Ko (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-45?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb closed EXEC-45.
--------------------


> Error while executing a command like echo
> -----------------------------------------
>
>                 Key: EXEC-45
>                 URL: https://issues.apache.org/jira/browse/EXEC-45
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>         Environment: OS: Windows XP SP3
>            Reporter: varma
>
> Hello,
> After looking at the javaDoc for DefaultExecutor, I've tried a simple command that does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.
> This is what I'm trying:
> {code:title=CommandExec.java|borderStyle=solid}
> public final void executeEcho()
> {
>       try
>       {
>          final CommandLine command = new CommandLine( "echo someValue" );
>          command.addArgument( "> c:\test.txt" );
>          final DefaultExecutor executor = new DefaultExecutor();
>          final int value = executor.execute( command );
>          System.out.println(value);
>       }
>       catch(Exception e)
>       {
>          e.printStackTrace();
>       }
> }
> {code}
> Exception being thrown:
> {code:title=exception}
> java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessBuilder.start(Unknown Source)
> at java.lang.Runtime.exec(Unknown Source)
> at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
> at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
> at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
> at testing.CommandExex.main(CommandExex.java:15)
> Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessImpl.create(Native Method)
> at java.lang.ProcessImpl.<init>(Unknown Source)
> at java.lang.ProcessImpl.start(Unknown Source)
> ... 8 more
> {code}
> From DefaultExecutor's JavaDoc:
> {code}
> Executor exec = new DefaultExecutor();
> CommandLine cl = new CommandLine("ls -l");
> int exitvalue = exec.execute(cl);
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (EXEC-45) Error while executing a command like echo

Woonsan Ko (Jira)
In reply to this post by Woonsan Ko (Jira)

     [ https://issues.apache.org/jira/browse/EXEC-45?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved EXEC-45.
----------------------

    Resolution: Invalid

"echo" is not a valid executable; it is a  built-in DOS command, so the behaviour of EXEC is correct.

Also, JIRA is not a support forum; please address usage questions to the Commons User list.


> Error while executing a command like echo
> -----------------------------------------
>
>                 Key: EXEC-45
>                 URL: https://issues.apache.org/jira/browse/EXEC-45
>             Project: Commons Exec
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>         Environment: OS: Windows XP SP3
>            Reporter: varma
>
> Hello,
> After looking at the javaDoc for DefaultExecutor, I've tried a simple command that does an "echo" and re-direct the output to a file. But, I'm getting "IOException". Not sure what I am missing here or is it possible to execute a command directly without specifying the path to an executable? I appreciate your help.
> This is what I'm trying:
> {code:title=CommandExec.java|borderStyle=solid}
> public final void executeEcho()
> {
>       try
>       {
>          final CommandLine command = new CommandLine( "echo someValue" );
>          command.addArgument( "> c:\test.txt" );
>          final DefaultExecutor executor = new DefaultExecutor();
>          final int value = executor.execute( command );
>          System.out.println(value);
>       }
>       catch(Exception e)
>       {
>          e.printStackTrace();
>       }
> }
> {code}
> Exception being thrown:
> {code:title=exception}
> java.io.IOException: Cannot run program "echo someValue": CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessBuilder.start(Unknown Source)
> at java.lang.Runtime.exec(Unknown Source)
> at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
> at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)
> at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149)
> at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136)
> at testing.CommandExex.main(CommandExex.java:15)
> Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
> at java.lang.ProcessImpl.create(Native Method)
> at java.lang.ProcessImpl.<init>(Unknown Source)
> at java.lang.ProcessImpl.start(Unknown Source)
> ... 8 more
> {code}
> From DefaultExecutor's JavaDoc:
> {code}
> Executor exec = new DefaultExecutor();
> CommandLine cl = new CommandLine("ls -l");
> int exitvalue = exec.execute(cl);
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.