Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Linux batch file from windows in java (!)

Status
Not open for further replies.
May 13, 2002
75
GB
Hi,

Maybe not strictly a java question but... i have a Java program i am working on, it runs on a Windows PC and needs to do the following:

1.) Copy a file from windows to a Linux server

Easy enough, set up samba on linux and use java.io classes.

2.) Execute a batch file (.sh) on the Linux server which runs a program which does stuff on the server to the previously copied file

3.) Read data froma new file which has been created from step 2.)


Steps 1 and 3 are not a problem, however, i am stuck on 2. Any ideas ? I can't just run the batch file from windows as i want it to run on the server (not the machine that is calling the script). I didn't want to go down the route of having a java "server" sitting on the Linux machine which i could contact and tell it to run the batch, what other options do i have ?

Thanks for any ideas




Alistair [monkey]
 
None (that I can think of) !

Basically you are asking how to start other processes (ie a shell script on linux) from a remote computer - ie you are attemping distributed computing.

For this, I would look into RMI - see the tutorials at
 
Thanks Sedj, i guessed i would have to use RMI maybe. One other option maybe to set up a Java daemon on the server polling for a file to be created, once it appears then i could get it to fire the script off using Runtime.exec()

Is there a good way to listen for a file being created in java (i.e. some kind of event listener) or do i need to poll on a timer (which is a bit nasty) ?

Thanks

Alistair [monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top