trouble with Runtime.getRuntime().exec(cmd) on Linux
From: JW (jkpangtang_at_yahoo.com)
Date: 12/27/03
- Previous message: Fred: "Anybody use Java with USB devices?"
- Next in thread: hiwa: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Reply: hiwa: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Reply: Scott Lurndal: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Dec 2003 17:46:46 -0800
Hi,
I don't seem to get any results from the following use
of Runtime.getRuntime().exec(cmd) using Java 1.4 on
Redhat linux.
Suppose that in the same directory as my java file below,
I have files junk1, junk2, junk3, and i want
to have the java program delete all of these files.
However, when I run the following code,
no deletion occurs.
What am I doing wrong?
---
import java.lang.Runtime;
import java.io.*;
public class Commandline
{
String[] cmd = { "rm", "-f","junk*"};
// String[] cmd = { "/bin/sh","rm", "-f","junk*"}; //doesn't work either
public Commandline()
{
try
{
Process pro = Runtime.getRuntime().exec(cmd) ;
}catch (IOException e)
{
System.err.println("ioexception starting process! " + e);
}
}
public static void main (String [] args)
{
Commandline c = new Commandline();
}
}
---
- Previous message: Fred: "Anybody use Java with USB devices?"
- Next in thread: hiwa: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Reply: hiwa: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Reply: Scott Lurndal: "Re: trouble with Runtime.getRuntime().exec(cmd) on Linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|