how to execute a unix shell script from a java program
Hi All,
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...
Please see the below details...and read the details carefully.
I have written some code, logic is
1)from UI we will get one file on window
2)from window that file will save on server i.e on /home/user01/trial1/csvfile.txt (This is successfully downloaded on the server)
3)that file we are passing to the script name-"omsSB.sh"
and output will save in csvfileout.txt
In below code everytnig is fine .From UI I am able to pass the tuple and also fetch the output file but iam unable to execute the omsSb.sh script
Question--> SCRIPT_NAME =./omsSb.sh is it the correct command or i need to right--- /home/user01/trial1/omsSb.sh. tried some of these like but script is not running.
This below code i have write in eclipse properties file , where i can mentioen the all the details of server.
1) if you run :
This suppose that you already are in the directory hosting that script
It also suppose that your user is granted (at least) to read that script (if you want to run it in the way mentionned above, you also must have execution right on it)
It also suppose that your script has the execution right (chmod +x yourscript).
If the execution right are not set for your file you can try to run it like :
Hi I am trying to implement one program, where JAVA needs to trigger the backend UNIX script. Tried with options like
String cmdArray = {"/bin/ksh","-c","/SCRIPT_ABSOLUTE_PATH/sampleScript.ksh /FILE_ABSOLUTE_PATH Test_File.dat TEST E SFTP"}
When I trigger the script from front end with... (1 Reply)
Hi Team,
Can you pls advise in java how can we call a shell script, actly I have a shell script at the following location
/opt/dd/ajh.sh
now I can execute this script by opening the session through putty by entering the servers details and password and then navigating to the following... (2 Replies)
Hi,
I have create a Shell Script, with one function.
I want to call the script file in Java Program.
It working fine. but the problem is the function in the Shell Script is not executed.
Please suggest me,
Regards,
Nanthagopal A (2 Replies)
Hi,
We are having a java server which can run on command line and once initiated, it will prompt options to enter from 0 to 5. The java program kickoff respective operation once number is entered between 0 to 5. However i want to always enter "1" and write another shell program wrapper to start... (4 Replies)
Hi,
I'm trying to test one unix shell script in dev environment. But I'm not sure how to pass the environment in my java program calling code. I'm trying to use -DconsumerEnv="DEV" but unfortunately I get 'null' while trying to print the value from java class.
System.out.println("Environment: "+... (4 Replies)
Hi,
i want to write a script that executes a program (exec?) .
this program then requires a filename as input.
how do i give it this input in the script so the program will be complete run and close by the script.
e.g.
exec prog.exe
program then asks for filename
"enter filename:"... (1 Reply)
hello all
how can i run the java command that can eccept N numbers of args for example :
java -cp .;foo.jar myApp 1 "ww"
or
java -cp .;foo.jar myApp 1 2 3 "ww"
or
java -cp .;foo.jar myApp "args1" "args2" "args3"
Thanks (1 Reply)
Members,
I been faced with an issue where i have to sale my project against JAVA.would like to know more on the strong point of shell script (bash shell) over java.I have a very limited knowledge on java.is there anyone who has worked on java and shell scripting in both and really been able to... (13 Replies)