• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Running a dos file from within Java

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use HTTP file upload; see, for example, here.
 
Message for you sir! I think it is a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!