GnuPG with Java waitFor() method on Windows?

Ruke Wang ruke@servgate.com
Tue Jul 29 18:55:02 2003


Thank you for the input.

Using System.out.println(cmd), I could see my dos command, and if I copy
that command directly in a dos prompt, there is no problem.

I added --batch and --no-tty and --yes options, but still the same thing.
The file is decrypted and saved in the proper folder but waitFor() still
does not return.  No error, no exception.

Thanks,
Ruke

-----Original Message-----
From: Joseph Bruni [mailto:jbruni@mac.com]
Sent: Monday, July 28, 2003 7:35 PM
To: gnupg-users@gnupg.org
Subject: Re: GnuPG with Java waitFor() method on Windows?


It might be waiting for some input from your program. Add the --batch 
and --no-tty options to make sure that it doesn't prompt you for 
something. Does the secret key have a passphrase? If so, that's what 
it's waiting for.


On Monday, July 28, 2003, at 06:55 PM, Ruke Wang wrote:

> I am trying to use java Runtime.getRuntime().exec() to call gnupg to 
> decrypt
> encrypted file.  However, even though the file is properly decrypted,
> waitFor() never returns.  The problem does not occur while I tried to 
> verify
> a signed data file.  By the way, is Java SDK1.4 Gnupg compatible?
>
> Thanks,
> Ruke Wang
>
> Here is my code, quite simple:
>
> import java.io.*;
>
> public class LicenseXmlTest
> {
> 	public static void main(String[] args)
> 	{
> 			TestXml tester = new TestXml();
> 			tester.Verify("d:\\test\\test.key");
> 	}
> }
>
> class TestXml
> {
> 	private String ExpireDate;
>
> 	private static String gpg_cmd = "c:\\gnupg\\gpg ";
> 	private static String home_dir = "--homedir d:\\test ";
> 	private static String key_ring = "--keyring ppp.asc --secret-keyring
> sss.asc ";
> 	private static String decrypt_para = "--decrypt ";
> 	private static String output_para = "--output ";
> 	private static String license_file = "d:\\test\\test.txt ";
> 	
> 	public TestXml()
> 	{
> 		ExpireDate = new String("01/01/1970");
> 	}
> 	
> 	public boolean Verify(String infile)
> 	{
> 		try
> 		{
> 			String cmd = gpg_cmd + home_dir + key_ring +
> output_para + license_file + decrypt_para + infile;
> 			Process opengpg = Runtime.getRuntime().exec(cmd);
> 			System.out.println(cmd);
> 			
> 			opengpg.waitFor();
> 			
> 			return true;
> 		}
> 		catch(IOException e)
> 		{
> 			System.err.println("Verify() ioexception" +
> e.toString());
> 			return false;
> 		}
> 		catch (InterruptedException e)
> 		{
> 			System.err.println("Verify() interrupt" +
> e.toString());
> 			Thread.currentThread().interrupt();
> 			return false;
> 		}
> 	}
> }
>
> _______________________________________________
> Gnupg-users mailing list
> Gnupg-users@gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gnupg-users
>


_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users