exec with stdin stdout

Discussion in 'Java' started by Paul Gessos, Sep 6, 2005.

  1. Paul Gessos

    Paul Gessos Guest

    Why this code not working?


    byte[] buf = new byte[10000];
    Process p = Runtime.getRuntime().exec("php -n 1.php");
    p.getErrorStream().close();
    InputStream is = p.getInputStream();
    OutputStream os = p.getOutputStream();
    os.write("write serialized data...".getBytes());// never takes data
    p.waitFor();
    int count = is.read(buf); // count == -1
    System.out.println(buf); // write garbage
    System.exit(0);
    Paul Gessos, Sep 6, 2005
    #1
    1. Advertising

  2. On Tue, 06 Sep 2005 19:27:52 +0300, Paul Gessos wrote:

    > Why this code not working?


    Maybe it is lazy. Did you try flogging it?

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    "If we fall, others are rising.."
    Paul Kelly 'From Little Things, Big Things Grow'
    Andrew Thompson, Sep 6, 2005
    #2
    1. Advertising

  3. Paul Gessos

    Guest Guest

    >>Why this code not working?
    >
    > Maybe it is lazy. Did you try flogging it?


    I respect personality of my programs. You are a Nazi scum!


    Have you a better answer?
    Guest, Sep 6, 2005
    #3
  4. On Tue, 06 Sep 2005 20:10:29 +0300, <- Chameleon -> wrote:

    >>>Why this code not working?

    >>
    >> Maybe it is lazy. Did you try flogging it?

    >
    > I respect personality of my programs. You are a Nazi scum!
    >
    >
    > Have you a better answer?


    Better than 'You are a Nazi scum!'?

    ...try my answer on the other (sub) thread.

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    "..When after all, it was you and me."
    The Rolling Stones 'Sympathy For The Devil'
    Andrew Thompson, Sep 6, 2005
    #4
    1. Advertising

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. Guest

    exec with stdin stdout

    Guest, Sep 6, 2005, in forum: Java
    Replies:
    4
    Views:
    1,125
    Roedy Green
    Sep 6, 2005
  2. Bernard
    Replies:
    4
    Views:
    5,371
    Raymond DeCampo
    Jan 3, 2006
  3. Johnathan Doe

    peek at stdin, flush stdin

    Johnathan Doe, May 15, 2004, in forum: C Programming
    Replies:
    5
    Views:
    24,927
    Chatoyer
    May 17, 2013
  4. Charlie Zender

    Reading stdin once confuses second stdin read

    Charlie Zender, Jun 19, 2004, in forum: C Programming
    Replies:
    6
    Views:
    783
    Dan Pop
    Jun 21, 2004
  5. Ben
    Replies:
    2
    Views:
    1,337
    jacob navia
    Aug 29, 2009
Loading...

Share This Page