commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Wamara" <daol...@hotmail.com>
Subject Re: Commons Exec not producing the same result as the command line
Date Wed, 14 Apr 2010 07:42:40 GMT
Thanks but I don't think this will help solve the problem as I can see in 
the log that the command which is executed is the correct one and as said, 
copy-pasting the command seen in the logs is producing a file completely 
different than the one created by Commons Exec.

Regards,
Daniel W.

--------------------------------------------------
From: "sebb" <sebbaz@gmail.com>
Sent: Wednesday, April 14, 2010 1:18 AM
To: "Commons Users List" <user@commons.apache.org>
Subject: Re: Commons Exec not producing the same result as the command line

> On 13/04/2010, Daniel Wamara <daolwin@hotmail.com> wrote:
>> Good evening all,
>>
>>  I am trying to call ffmpeg via the command exec in order to transcode 
>> some files and the strange thing happening is that the files produced are 
>> not the same as the one I can create when calling the same command via 
>> the command line.
>>
>>  This is how I am calling fmpeg and I get a file with a particular codec 
>> in it (strangely not the right one) although launching in the command 
>> line exactly what I have in the sb.toString() which is the command to be 
>> executed, the file created has a correct codec. So to say, the same 
>> command started via Exec and the one started via the command line have 
>> not the same result. Anyone has an idea?
>>
>>  Thanks.
>>  Daniel Wamara
>>
>>  StringBuilder sb = new StringBuilder("/home/ect/scripts/transcoding.sh 
>> ");
>>
>>  sb.append(" " + source.getAbsolutePath());
>>
>>  sb.append(" " + attributes.getCodec());
>>
>>  sb.append(" " + 
>> String.valueOf(attributes.getSamplingRate().intValue()));
>>
>>  sb.append(" " + target.getAbsolutePath());
>>
>>
>>  logDebug("command --> " + sb.toString());
>>
>>
>>  CommandLine commandLine = CommandLine.parse(sb.toString());
>
> Why do you build up the command-line and then parse it?
>
> Much safer to add the arguments one at a time, see:
>
> http://commons.apache.org/exec/tutorial.html
>
> under the heading "Build the Command Line Incrementally"
>
>
>>  DefaultExecutor executor = new DefaultExecutor();
>>
>>  executor.execute(commandLine);
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message