Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Running a dos file from within Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running a dos file from within Java" Watch "Running a dos file from within Java" New topic
Author

Running a dos file from within Java

Simon Haywood
Greenhorn

Joined: Sep 02, 2003
Posts: 6
Hi,
I trying to run a dos .bat file (which try's to ftp a file from my work station to a unix directory) from within my java application which is running on a local intranet from a unix platform.
Firstly is this possible.?, as I've tried using runtime exec command, but this seems to be using the unix environment to execute my file, which is not there, but located on my work station instead.
Thanks in advance for any help.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Simon,
Welcome to JavaRanch!
Runtime.exec() runs an external program on the same machine as the JVM that called Runtime.exec(). In general, if one machine A wants to run a program on another machine B, the only way to do it is for A to send a message to some software on B requesting that the program be run. This "some software on B" can take many forms, depending on the circumstances.
Anyway, if you need more info, your explanation is a little hard to follow. Let's say there's a Windows computer A, and a UNIX computer B. Now, tell us, using "A" and "B", what the role of each computer is.


[Jess in Action][AskingGoodQuestions]
Simon Haywood
Greenhorn

Joined: Sep 02, 2003
Posts: 6
Originally posted by Ernest Friedman-Hill:
Hi Simon,
Welcome to JavaRanch!
Runtime.exec() runs an external program on the same machine as the JVM that called Runtime.exec(). In general, if one machine A wants to run a program on another machine B, the only way to do it is for A to send a message to some software on B requesting that the program be run. This "some software on B" can take many forms, depending on the circumstances.
Anyway, if you need more info, your explanation is a little hard to follow. Let's say there's a Windows computer A, and a UNIX computer B. Now, tell us, using "A" and "B", what the role of each computer is.
Simon Haywood
Greenhorn

Joined: Sep 02, 2003
Posts: 6
Oops, you can tell I'm new at this...
The situtation I have based on A being a windows computer (client), and B a unix computer (server) is;
The URL entered in the browser on A points to a java application running on B. I then wish to transfer files from A to B, so they can be imported into the application's database at a later stage.
If I understand correctly, then this is not possible using Runtime.exec(), as the JVM is machine B.
Any other suggestions on how to connect to machine A to get the files to transfer to B...?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You can use HTTP file upload; see, for example, here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running a dos file from within Java
 
Similar Threads
Upload a file to unix and invoke a java method
A Quest for all of those who don't use RI for HF EJB
JDBC API Test suite 1.3.1
Really, really stupid question
Loadjava program