Calling BASH script from JAVA

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Calling BASH script from JAVA
# 1  
Old 05-23-2011
Calling BASH script from JAVA

Hi,

I am trying to call a bash script from a java file.

Code to call bash script will look like:

Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("mybashfile.sh");

It is succesfully calling the bash file.

I am using simple rm commands in the script to remove files and directories and it is removing those correctly.

But, when i use sleep between the rm commands, files and directories are not getting removed.

I am new to Linux. Please tell me what should i do
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Calling bash script from CGI

Hi, I am having two individual scripts Script 1): CGI script - is a simple script which trigger bash script Script 2): Bash script - is a script which execute which collects file system utilization information from all the Unix servers If I am executing CGI script manually from command... (2 Replies)
Discussion started by: Naveen.6025
2 Replies

2. Shell Programming and Scripting

Calling msys shell from bash script

Hi all, I am struck at a very tricky problem. Writing a bash script that calls msys.bat which inherently launches sh.exe. Now from my bash script, I call msys.bat and it creates a shell within. The problem is: I cannot pass any commands to this new shell from my bash script. I need to be able to... (5 Replies)
Discussion started by: sweetu1995
5 Replies

3. Shell Programming and Scripting

Password check in bash script calling on expect

password check in bash script calling on expect Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all linux servers. most of them have the same... (1 Reply)
Discussion started by: 2legit2quit
1 Replies

4. Shell Programming and Scripting

Calling function from another bash script

I would like to call functions from another bash script. How can I do it? Some code More code (11 Replies)
Discussion started by: kristinu
11 Replies

5. Shell Programming and Scripting

How to pass the environment name while calling java program from unix script?

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)
Discussion started by: Pramit
4 Replies

6. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

7. Shell Programming and Scripting

Quick question: calling c-shell script from bash

Hello, I have a quick reference question: I have a very long, but fairly straigtforward script written in c-shell. I was wondering if it is possible to call this script from bash (for ex. having a function in bash script which calls the c-shell script when necessary), and if so, are there any... (1 Reply)
Discussion started by: lapiduslost
1 Replies

8. Shell Programming and Scripting

Calling bash command in perl script

Hi, I have tried several times but failed, I need to call this script from the perl script. This one line script will be sent to /var/tmp/error Bash command: /usr/openv/netbackup/bin/admincmd/bperror -backstat -l -hoursago 12 |awk '{ print $19, $12, $14, $16}'|grep -vi default|sort >... (12 Replies)
Discussion started by: sQew
12 Replies

9. Shell Programming and Scripting

Calling Java Method from UNIX using shell script

Hi All, I need to call a java method from a shell script. I know we can use the command java ClassName to call the main method in it. But I need to call another method that is there in the class and pass an email to it. Can I use java ClassName.MethodName(email) Any help will be... (4 Replies)
Discussion started by: RahulK
4 Replies

10. UNIX for Dummies Questions & Answers

calling a script from java

HI I need to build a GUI where a button could execute a script in Solaris 8. I am working with Sun ONE Studio 7 Enterprice Edition. Thanks (1 Reply)
Discussion started by: javierelizabeth
1 Replies
Login or Register to Ask a Question
UPDATE-JAVA-ALTERNATIVES(8)				      System Manager's Manual				       UPDATE-JAVA-ALTERNATIVES(8)

NAME
update-java-alternatives - update alternatives for jre/sdk installations SYNOPSIS
update-java-alternatives [--jre] [--plugin] [-t|--test|-v|--verbose] -l|--list [<jname>] -s|--set <jname> -a|--auto -h|-?|--help DESCRIPTION
update-java-alternatives updates all alternatives belonging to one runtime or development kit for the Java language. A package does pro- vide these information of it's alternatives in /usr/lib/jvm/.<jname>.jinfo. OPTIONS
-l|--list [<jname>] List all installed packages (or just <jname>) providing information to set a bunch of java alternatives. Verbose output shows each alternative provided by the packages. -a|--auto Switch all alternatives of registered jre/sdk installations to automatic mode. -s|--set <jname> Set all alternatives of the registered jre/sdk installation to the program path provided by the <jname> installation. --jre Limit the actions to alternatives belong to a runtime environment, not a development kit. --jre-headless Limit the actions to alternatives belong to the headless part of a runtime environment. --plugin Limit the actions to alternatives providing browser plugins. -h|--help Display a help message. -t|--test Don't actually do anything, just say what would be done. The implementation status of this option is the same as for update-alter- natives (not implemented). -v|--verbose Verbose output. FILES
/usr/lib/jvm/.*.jinfo A text file describing a jre/sdk installation. Consists of some variables of the form <var>=<value> and a list of alternatives of the form jre|jdk <name> <path>. AUTHOR
update-java-alternatives and this manual page was written by Matthias Klose <doko@ubuntu.com>. May 2006 UPDATE-JAVA-ALTERNATIVES(8)