how to execute a unix shell script from a java program

Ads
 

how to execute a unix shell script from a java program

well , i am facing this problem.. i have tried a few sample codes but there isn't any solution . could anyone please give a sample code as of how to do this...

what i am trying is that there we can enter a username,server name and a password alongwith the script name from a java code .once you execute this java program ultimately your script gets executed.. it would be a lot of help to me..

View Answers

November 11, 2011 at 1:43 AM

Well its easy man,

You should be on a linux box for doing this.

Java has a Runtime class using which you can execute commands.

But in your case, what can be done is:

Process processObj = Runtime.getRuntime().exec("sh yourScriptName.sh");

Hope it helps.

Reno Jones

Ads









Related Tutorials/Questions & Answers:
how to execute a unix shell script from a java program
how to execute a unix shell script from a java program  well , i am... the script name from a java code .once you execute this java program... solution . could anyone please give a sample code as of how to do this... what i am
How I get a variable from java script to use it in the scriptlet of jsp.
How I get a variable from java script to use it in the scriptlet of jsp.  Hi i want to get the tinyUrl value in the scriptlet of jsp. // Bit.ly API var url="http://cplive.com/dealDetail.do?method=displayDealDetail&
Advertisements
Java Script Program
Java Script Program  <%-- Document : index Created... () that prevented it from fulfilling this request. exception... are available in the Sun Java System Application Server 9.1 logs. Sun Java System
Java Script Program
Java Script Program  <%-- Document : index Created... () that prevented it from fulfilling this request. exception... are available in the Sun Java System Application Server 9.1 logs. Sun Java System
How to read PDF files created from Java thru VB Script
How to read PDF files created from Java thru VB Script  We have created the PDF file thru APache FOP but when we are unable to read the data thru... file?   Java PDF Tutorials
Merging of java script with servlet program
Merging of java script with servlet program  how can we merge the java script with the any servlet program for making web application intractive.Is there any program you have.\please help me to sove out this problem
Execute the java program using one processor
Execute the java program using one processor   Write a program to print the number series 1, 2,3, 4ΓΆβ?¬Β¦.100 using java programming language in dual core computer a) Execute the program using one processor b) Execute
how to write to java program to get the particular data from the website
how to write to java program to get the particular data from the website   i have to get the particular data by selecting the just numbers.. from the site .. how to get the ful details from the website by clicking the number
Example program to pass value from Html to java script
Example program to pass value from Html to java script... html code to java script easily. To show this we have created an example Html page which will pass the value to the java script function and this value
How to create a .mdf file from script (.sql)
How to create a .mdf file from script (.sql)  Hi, I have a sql database in 2008 server. now i want it to convert to 2005. so i script it. just help me to create a .mdf file back from the script
How to run PHP Script from the command line ?
How to run PHP Script from the command line ?  Running PHP Script from the command line   Actually it is very simple to run php script... expect. You can also check : http://www.phpzag.com/running-php-script-from
how to execute a file in java at regular time intrevals automattically
how to execute a file in java at regular time intrevals automattically  how to execute a file in java at time retrievals automatically
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
How can java programs execute automatically when it connects to network
How can java programs execute automatically when it connects to network  Good Day dears... How can java programs execute automatically when... internet Connection through my java program
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
WAS server configuration from JAVA program
WAS server configuration from JAVA program  How to get web sphere server status like heap,connection pool properties,stall counts etc. from a java applciation
execute a PHP script using command line
execute a PHP script using command line  How can I execute a PHP... Line Interface) program and provide the PHP script file name as the command line... the CLI program. Be aware that if your PHP script was written for the Web CGI
how to run java program
how to run java program  i have jar file. in jar i have so many classes.in one of file i want modify .after modifying file i want replce in jar. please help me to how to generate class and how to replace
how to call java script function through java class file
how to call java script function through java class file  how to call jframe in java script
How to compile and run Java program
How to compile and run Java program  How to compile and Java program..., For compiling and running the Java program from command prompt you should must have JDK... tutorial Compiling and Running Java program from command line. If Java
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
How to execute mysql query based on checkboxes values in java swing application.
How to execute mysql query based on checkboxes values in java swing application.  Hello Sir, I have a java swing application and i have to execute query based on selection of checkboxes.Means I have to to execute
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive... command line and it works. I copied all java files and class files to flash drive... package. I have to use following line on command line to compile and run my program
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile
Java Script
Java Script  What is Java Script? How to learn Java Script?   Hi Java Script is client side programming language. It runs on browser.... You can learn Java Script from our JavaScript - JavaScript Tutorial pages
How to create first Java Program?
How to create first Java Program?  Hi, I am beginner and I want to write first Java program. How I can setup my machine and write first Java program... on creating First Java Program Thanks   HI, Here are the steps to write
How to Program in Java
This tutorial tells you how to program in Java? As a beginner you must know how to start programming in Java. Java is programming language which can be used... program) for more details on "How to Program in Java?". Create simple
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks

Ads