N
nico_zin
I have written a Java class that performs a
Runtime.getRuntime().exec(cmd). The contents of 'cmd' in this case is
the 'gpg' utility that depends quite a bit on stdin/stdout. I have
built a simple command-line interface to this class for testing
purposes. When testing, the utility works perfectly. However, when
the class is packaged up and attempted to be used from a Windows
Service for example, it fails.
Initially, my 'cmd' contained "gpg --passphrase-fd 0 ..." and failed
(error=2) with regards to the --passphrase-fd 0 reference. I then
updated the 'cmd' reference to be "cmd /c gpg ..." and failed elsewhere
throwing an IOException.
Hunting around, the Java.io.Process class definition documents:
"...The created subprocess does not have its own terminal or console.
All its standard io (i.e. stdin, stdout, stderr) operations will be
redirected to the parent process through three streams
(Process.getOutputStream(), Process.getInputStream(),
Process.getErrorStream()). The parent process uses these streams to
feed input to and get output from the subprocess."
I take it when running from a Windows service implies the parent
process doesn't have standard I/O.
I'm not sure if a simple solution is possible. Any help would be
appreciated.
thanks.
Runtime.getRuntime().exec(cmd). The contents of 'cmd' in this case is
the 'gpg' utility that depends quite a bit on stdin/stdout. I have
built a simple command-line interface to this class for testing
purposes. When testing, the utility works perfectly. However, when
the class is packaged up and attempted to be used from a Windows
Service for example, it fails.
Initially, my 'cmd' contained "gpg --passphrase-fd 0 ..." and failed
(error=2) with regards to the --passphrase-fd 0 reference. I then
updated the 'cmd' reference to be "cmd /c gpg ..." and failed elsewhere
throwing an IOException.
Hunting around, the Java.io.Process class definition documents:
"...The created subprocess does not have its own terminal or console.
All its standard io (i.e. stdin, stdout, stderr) operations will be
redirected to the parent process through three streams
(Process.getOutputStream(), Process.getInputStream(),
Process.getErrorStream()). The parent process uses these streams to
feed input to and get output from the subprocess."
I take it when running from a Windows service implies the parent
process doesn't have standard I/O.
I'm not sure if a simple solution is possible. Any help would be
appreciated.
thanks.