----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Nick Bauman wrote:
> Keith Ball <[EMAIL PROTECTED]> wrote:
> >          Runtime.getRuntime().exec("mkdir
> > ItWorked");
> 
> Any reason why you are using Java to do (non-portable)
> shell scripting? ;)

For me its because I know more about Java than I do about CGI or Perl.
The code that I am doing does not have to switch platforms, it is being
written for a Linux platform because that is the platform its going to
run on. :)

> Seriosuly, I should think this would be a lot easier
> to make and manipulate a file / dir with java.io.File,
> et al.

It works quite well with just running using the Process and Runtime
classes. Granted it takes a little fiddling till you know it works but
from then its fine.


        Runtime.getRuntime().exec("cd /tmp ; mkdir T");

should work fine, no matter what user Jserv is running as.


        Process process = Runtime.getRuntime().exec("ls");

        BufferedReader br = new BufferedReader(new 
                InputStreamReader(process.getInputStream()));

        String line;

        while((line = in.readLine()) != null) {
                out.println(line);
        }


the above code prints out the result of an ls directory listing

Rob


--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to