• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

invoke batch file on a remote machine

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to invoke an utility called "bcp" which is used to copy bulk data into Syabase Adaptive server.In my case I would need to upload rows to the tune of 2-3M.
Now this bcp utility is a batch file(or shell script) sitting in the machine having the adaptive server.
I need to invoke it remotely from a servlet which is running in a web server on some other machine.How can this be done in java?

Also as the process is asynchronous I would need some way of figuring out that the process has completed so that a confirmation mail can be send to the user who had invoked it.Any ideas on how this can be done?

Thanks in advance,
Sunetra.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To run anything on another machine you need some kind of remote protocol with a client on your end and a server on the other end. Choices run from dead simple to very complex - sockets, RMI, JMS, web services, EJBs, some utilitiy that's already on the server, etc. You might get lucky here ... could you call a stored procedure in the Sybase server that then runs the batch job? Once you get the protocol down we can think about how to make it asynchronous (if it's not already) and look for results.
 
Sunetra Sen
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
It looks like I can have the bcp batch file locally in the same machine as my webserver.
So the first part of the problem gets solved.I can use Runtime.exec() to execute it I guess.
However still thinking about the second part..should I start the batch process by spawning a new thread so that when the Runtime.exec() method retirns back we could send back an email or somthing to the user.I would probably put this whole thing in the run method.This would get started from a pop-up servlet(that Thread.start() would be called from a pop up servlet) so that the user might close the pop-up window and do something else(or go for a beer! ).But the thread would keep running in the background and whenever the process is over the user gets an email notification.

Does this sound good?
Please comment..any other idea is also welcome.

Thanks,
Sunetra.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A popup that says you will receive mail soon sounds like some registration and shopping sites I've been through, so your users will likely find it familiar or easy to follow.

My current project starts an applet in the browser. The applet opens a server socket so the server can push messages to the browser. That's a lot of work, but it is one way to notify the user that the asynchronous process has finished.
 
reply
    Bookmark Topic Watch Topic
  • New Topic