Page 1 of 1

NConvert process returns exit code -2

Posted: Wed Apr 21, 2010 9:22 am
by Arvind
Hi,
I am trying to run nConvert command on a input file to convert it into a JPG.
This is being done from a Java program using Runtime class.
Code snippet is as below:

Code: Select all

		Runtime app = Runtime.getRuntime();
		Process proc;
		try
		{
			proc = app.exec(cmd.toString(), null, workingDirectory);
		}

int exitcode = proc.waitFor();
if(exitcode = 0){
 boolean bsucess = true;
}
The variable cmd in this code has the nconvert command line statement.
This code is giving the exitcode value as -2.
What does this exit code represent?
How to fix it?
Please provide information.

Thanks
Arvind

Re: NCovert process returns exit code -2

Posted: Wed Apr 21, 2010 2:13 pm
by xnview
exit code is -2, but the convert failed?

Re: NCovert process returns exit code -2

Posted: Thu Apr 22, 2010 4:10 am
by Arvind
Yes, the conversion failed.

Re: NCovert process returns exit code -2

Posted: Thu Apr 22, 2010 6:31 am
by xnview
Arvind wrote:Yes, the conversion failed.
-2 is a global error. What do you see when you exec it?

Re: NCovert process returns exit code

Posted: Wed Jun 02, 2010 11:07 am
by Arvind
I am trying to run nconvert on Linux programmatically.

The subprocess returned with exit code 254.

What does this mean?

The file was not generated.

Re: NCovert process returns exit code

Posted: Wed Jun 02, 2010 11:31 am
by xnview
Arvind wrote:The subprocess returned with exit code 254.
254? strange, there is no such error

Re: NCovert process returns exit code -2

Posted: Wed Jun 30, 2010 10:23 pm
by helmut
Just had a quick look at your Java code. Shouldn't it say:

Code: Select all

...
if (exitcode == 0) {
 boolean bsucess = true;
}
(please note the "==" for comparison instead of "=" for assignment)? Is your code snippet above complete? I assume that the Runtime.exec(..) call throws an exception which means that calling nconvert failed. The exception is simply ignored because there's no "catch", so you will never know and your exit code is undefined. I *strongly* recommend to add a "catch" block.

Re: NCovert process returns exit code

Posted: Thu Jul 01, 2010 9:53 am
by icabod
xnview wrote:
Arvind wrote:The subprocess returned with exit code 254.
254? strange, there is no such error
I would guess that as NConvert is being run programatically in this instance, then the return code is being put into an unsigned char? 254 == -2 in that case.

Just my input, and probably not helpful :)

'bod

Re: NCovert process returns exit code

Posted: Fri Jul 02, 2010 1:10 pm
by xnview
icabod wrote:is being put into an unsigned char? 254 == -2 in that case.
Yes :-) and NConvert return -2 if there is an error in the process. So you can perhaps check the output?

Re: NConvert process returns exit code -2

Posted: Tue Jul 06, 2010 1:36 pm
by Arvind
Hi,
I put try-catch block surrounding Runtime.exec() code. It shows the correct error.

Code: Select all

got the exception-->java.io.IOException: Cannot run program ""//data/stacks/nConvert/NConvert/nconvert"" : java.io.IOException: error=2, No such file or directory
The code was trying to run this command:

Code: Select all

Executing the command -->"//data/stacks/nConvert/NConvert/nconvert" -out png -truecolors  -o  "/data/Apparel/apache-tomcat-6.0.18/temp/fcs4973485609669380733/fe8216cf-59e2-4ea2-9f52-fa33c44fc285/generic/Pant_viewable.png" "/data/Apparel/apache-tomcat-6.0.18/temp/fcs4973485609669380733/fe8216cf-59e2-4ea2-9f52-fa33c44fc285/Pant.jpg"
This works perfectly on Windows machine; issue is only on Linux OS.
The error indicates that it could not find the path. I ran the command seperately on Linux OS. It works.

thanks
arvind

Re: NConvert process returns exit code -2

Posted: Tue Jul 06, 2010 2:05 pm
by xnview
Arvind wrote: This works perfectly on Windows machine; issue is only on Linux OS.
The error indicates that it could not find the path. I ran the command seperately on Linux OS. It works.
So not an error of NConvert. Here i can't help you more...

Re: NConvert process returns exit code -2

Posted: Tue Jul 06, 2010 9:37 pm
by helmut
Arvind wrote:I put try-catch block surrounding Runtime.exec() code. It shows the correct error.

Code: Select all

got the exception-->java.io.IOException: Cannot run program ""//data/stacks/nConvert/NConvert/nconvert"" : java.io.IOException: error=2, No such file or directory
The double slashes "//" in your file path look ambiguous to me. Also the quotation marks might cause a problem (just guessing).
Arvind wrote:This works perfectly on Windows machine; issue is only on Linux OS.
The error indicates that it could not find the path. I ran the command seperately on Linux OS. It works.
When running your command manually, did you use the quotation marks, too? This might be a permission problem, does your program have permission to execute "nconvert"?