The moose likes Servlets and the fly likes Firing statements into Command prompt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "Firing statements into Command prompt. " Watch "Firing statements into Command prompt. " New topic

Firing statements into Command prompt.

Gautam Dembla

Joined: Mar 23, 2005
Posts: 9
Wanted to know if there was a way i could fire a statement into command prompt and display the results on a label((eg. c:\>ping
and display the results of the ping response on a label(which is refreshed every 50 milliseconds)).Displaying the results can be done by capturing the response in a .txt file and maybe using a threaded IO operation and readind the response onto a label.
Purpose of me doing this is, i want to fire a logical backup of the database from the front-end, similarly restoration of the database from the front-end..
Like incase of VB 6.0, I could give a Shell command and the statement would be executed in the command prompt.
Thanx All..
Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
Your question should go into "Java in general" forum.

Use one of the exec() methods of java.lang.Runtime class to execute an external application or o/s command. The exec methods return an instance of Process class, which can be used to obtain the standard i/o related to the executing process.

Here is a quick example.

A google search with "java runtime exec process" brought me some useful results.
[ March 23, 2005: Message edited by: Susanta Chatterjee ]
Gautam Dembla

Joined: Mar 23, 2005
Posts: 9
hey thanx for the reply !!
i will try it in sometime, will keep u updated
sorry for having posted it in 2 differnt sections.
Will keep u posted abt my progress
Take Care
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63202

Guatam, please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Have you checked out Aspose?
subject: Firing statements into Command prompt.
It's not a secret anymore!