Java Process without console or terminal

Discussion in 'Java' started by nico_zin@yahoo.com, Sep 22, 2006.

  1. Guest

    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.
     
    , Sep 22, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gaurav kashyap
    Replies:
    3
    Views:
    7,146
    Paul Boddie
    Oct 31, 2008
  2. Chris Rebert

    Re: Password input in console/terminal

    Chris Rebert, Dec 9, 2008, in forum: Python
    Replies:
    1
    Views:
    377
    cadmuxe
    Dec 9, 2008
  3. rickman
    Replies:
    3
    Views:
    915
    HT-Lab
    Jan 7, 2009
  4. robert
    Replies:
    1
    Views:
    883
    Martin v. Löwis
    Jun 25, 2009
  5. Ulf Meinhardt
    Replies:
    1
    Views:
    1,098
    Andrew Thompson
    Aug 10, 2009
  6. Steve
    Replies:
    2
    Views:
    1,117
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
  7. Mickael Faivre-Macon
    Replies:
    2
    Views:
    257
    Kouhei Sutou
    Oct 10, 2006
  8. Lg Lg
    Replies:
    2
    Views:
    196
    Faster Rain
    Aug 17, 2010
Loading...