How to run the Shell Script from external directory using java?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run the Shell Script from external directory using java?
# 1  
Old 12-10-2012
How to run the Shell Script from external directory using java?

Hi,

I have created a Shell Script and invoke through java using Process Builder

It's working fine, if (Shell script file ) in the same directory as java file.

By Problem:

How to run the Shell Script file( resides in external directory) using java. What configuration i have to do in java.

Please Suggest me,

Thank you and Regards,
Nanthagopal A
# 2  
Old 12-10-2012
How about giving absolute path of your shell script as argument to ProcessBuilder class?
Code:
Process p = new ProcessBuilder("myCommand", "myArg").start();

Code:
Process p = new ProcessBuilder("/bin/bash", "/your_script_path/script.sh").start();

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Help with writing a script to run java commands in sequence in UNIX

Hi, Brand new to these forums, and I hope that someone can help me out. I'm trying to run the following command in UNIX java -jar GenomeAnalysisTK.jar -T SplitSamFile -dt NONE -R reference.fa -I my.bam --outputRoot /my/path/SampleFiles/Sample_ It executes the SplitSamFile from GATK, but I... (3 Replies)
Discussion started by: Wixaros
3 Replies

3. Shell Programming and Scripting

Cannot run this .java file from the home directory??

I wrote a simple test.java program in vi. I know it compiles correctly because I went into the directory where test.java was and compiled it and it created a java.class. I then ran test.java by staying in the same directory where it was and it worked great. However, when i backed out of the... (3 Replies)
Discussion started by: syregnar86
3 Replies

4. Shell Programming and Scripting

How to run java from shell

Hi All, I am trying to run a grep command which creates an output file. Then I will run a java file which take that file and process that. My java file uses other java files and library jars. I have tried below code but I am getting compilation error,it can not find other java files in same... (1 Reply)
Discussion started by: kmajumder
1 Replies

5. Shell Programming and Scripting

Shell script to run all the python scripts from particular directory

I have N number of python scripts which i am receiving from REST web server and i am saving them in /home/mandar/ . Now i want to write a script to run all the python scripts from this directory and monitor them every minute...if any process is dead or hung it should be restarted by this script. ... (0 Replies)
Discussion started by: Mandar Nandale
0 Replies

6. Shell Programming and Scripting

How to run perl script in remote machine from java application?

Hi I am working in a java application. I need to execute a perl script(linux) which is in remote machine in java application from local machine(windows). I need to do this process automatically that is without manual intereption. Now I will explain the process clearly, at present to run the... (1 Reply)
Discussion started by: bassma
1 Replies

7. UNIX for Advanced & Expert Users

run shell script in java?

hi, how to run shell script in java? i have script a.sh which takes 1 argument as input and returns exit code integer. how to handle it in java. should i have to invoke process to execute it and then wait til it completes ? please explain with code thanks (1 Reply)
Discussion started by: crackthehit007
1 Replies

8. Shell Programming and Scripting

querry ..including external shell script

is there any way to include one shell script into other like include in c apart from putting it in a function (3 Replies)
Discussion started by: mobydick
3 Replies

9. UNIX for Dummies Questions & Answers

run java using shell script

I have written a java file which runs fine when I compile and run it from the command prompt manually. i.e, >javac z.java >java z I have put these two lines in a executable file. But when I run the executable file, it throws an error 'Thread Exception'. Any thoughts? #executable file... (1 Reply)
Discussion started by: inpavan
1 Replies
Login or Register to Ask a Question