Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 64857 invoked from network); 23 Mar 2010 15:29:52 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Mar 2010 15:29:52 -0000 Received: (qmail 78112 invoked by uid 500); 23 Mar 2010 15:29:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 77948 invoked by uid 500); 23 Mar 2010 15:29:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 77932 invoked by uid 99); 23 Mar 2010 15:29:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Mar 2010 15:29:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Mar 2010 15:29:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 50EFC234C4AB for ; Tue, 23 Mar 2010 15:29:27 +0000 (UTC) Message-ID: <812241480.435991269358167330.JavaMail.jira@brutus.apache.org> Date: Tue, 23 Mar 2010 15:29:27 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Subject: [jira] Closed: (EXEC-45) Error while executing a command like echo In-Reply-To: <323561751.433241269349287473.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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.(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.