Danny,

Yes, you can execute a system command.  For example:

        Runtime shell = Runtime.getRuntime();
        File mappedDrive;
        int tries = 3;  // try the connection 3 times before reporting
an error

        while (tries-- > 0)
        {
                // create the drive mapping
                shell.exec("net use s: //Lab1");

                // check mapping
                mappedDrive = new File("S:\\");
                if (mappedDrive.isDirectory())
                {
                        // you're good to go

                        // break the loop
                        break;
                }
        }

        if (tries == -1)
        {
                // report connection errors
        }



Tim Gallagher

-----Original Message-----
From: Danny Rubis [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 26, 1999 7:20 PM
To: [EMAIL PROTECTED]
Subject: Re: Servlet/ftp Design ?


Hey!

Timothy I thought of doing that but with NT's files system I can only
map to a
maximum of 26 drives until I run out of map letters.  I think other
files
system and not restricted as such.

I could map a drive to say:

net use s: //Lab1

Then do my file transfer and when finished do this:

net use s: /delete /yes

But can I execute a system command from a servlet?



Timothy Gallagher wrote:

> Looks like a very good approach.  Your other options, if you stay with
> the central collection, would be to map-a-drive / mount-a-directory.
>
> Tim Gallagher
>
> -----Original Message-----
> From: Danny Rubis [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 25, 1999 9:22 PM
> To: [EMAIL PROTECTED]
> Subject: Servlet/ftp Design ?
>
> Hey!
>
> Given more than 100 computers collecting test lab data.  Each has a
> directory named C shared-out to the network, where log files are
written
> out to flat files.  Another computer collects all of the data from
each
> of the lab computers and stores it in a database.  A servlet provides
> access to the data to the Web browser.  The log files are not sent to
> the database computer, but reside on the test lab computers.
>
> Does it make sense to do this:
> Install a TFTP server on each of the test lab computers.
> Instantiate a URL connection.
> Get the log file.
>
> The servlet code to get the log files like this:
>
> ...
>  String host ="Lab1";                        // the name of the lab
> computer
>  String log="Log1.log";                    //the log file
>  String url = "ftp://" +host+ "/" +log";
>  try { this.theURL = new URL(url); }
>  catch ( MalformedURLException e) {
>    System.out.println("Bad URL: " + theURL);
>  }
> ...
> ...
>  URLConnection conn = null;
>  DataInputStream data = null;
>  String line;
>  StringBuffer buf = new StringBuffer();
>
>  try {
>    conn = this.theURL.openConnection();
>    conn.connect();
>
>    //Connection opened...
>    data = new DataInputStream(new BufferedInputStream(
>        conn.getInputStream()));
>
>     // get the log file
>    while ((line = data.readLine()) != null) {
>    buf.append(line + "\n");
>    }
>  }
>  catch (IOException e) {
>    System.out.println("IO Error:" + e.getMessage());
>  }
>
>
________________________________________________________________________
> ___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
________________________________________________________________________
___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

________________________________________________________________________
___
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to