🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.java.programmer
3 messages
3 total messages Started by Christoph Sperle Tue, 02 Nov 1999 00:00
Runtime.exec()
#408
Author: Christoph Sperle
Date: Tue, 02 Nov 1999 00:00
34 lines
1382 bytes
Hi,

I have a Problem with the exec-Method of the Runtime-Object. On the
DOS-Commandline this statement works propperly:

command.com /c copy C:\print.ps lpt1

but with the exec-Method it doesen't. Here is my Programm:


import java.io.*;

public class doscommand {

    public static void main (String[]args){

        int i;
        InputStream is;

        try{
            is = Runtime.getRuntime().exec("command.com /c copy C:\\print.ps
lpt1").getInputStream();
            while((i = is.read()) != -1) System.out.print((char)i);
        }
        catch(java.io.IOException e) {
            System.err.println(e.getMessage());
            System.exit(1);
    }
}


Why is this? Can anyone help me?

Thank you, christoph.
Re: Runtime.exec()
#409
Author: geoff_robinson
Date: Tue, 02 Nov 1999 00:00
51 lines
1888 bytes
Try breaking this apart so you can do a little debugging.

Process p = r.exec(command);
p.waitFor();

see if it works, then do the Input Stream stuff.

Geoff


In article <7vmjmm$s23$1@n.ruf.uni-freiburg.de>,
  "Christoph Sperle" <sperle@wi.ba-loerrach.de> wrote:
> Hi,
>
> I have a Problem with the exec-Method of the Runtime-Object. On the
> DOS-Commandline this statement works propperly:
>
> command.com /c copy C:\print.ps lpt1
>
> but with the exec-Method it doesen't. Here is my Programm:
>
> import java.io.*;
>
> public class doscommand {
>
>     public static void main (String[]args){
>
>         int i;
>         InputStream is;
>
>         try{
>             is = Runtime.getRuntime().exec("command.com /c copy
C:\\print.ps
> lpt1").getInputStream();
>             while((i = is.read()) != -1) System.out.print((char)i);
>         }
>         catch(java.io.IOException e) {
>             System.err.println(e.getMessage());
>             System.exit(1);
>     }
> }
>
> Why is this? Can anyone help me?
>
> Thank you, christoph.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: Runtime.exec()
#410
Author: Mohan Shenoy
Date: Wed, 03 Nov 1999 00:00
6 lines
754 bytes
What is the error message?

--
Mohan Shenoy
Email: shenoym@vsnl.com
http://personal.vsnl.com/mohans
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads