Passing Integers to shell script from java


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing Integers to shell script from java
# 1  
Old 03-30-2009
Passing Integers to shell script from java

i have to pass an integer value to shell script which will mail the values to users.
I am able to pass string values like this.

try {
String[] strCmdToRun1 = new String[] { "sh", "mail.sh","hello"};
Process p1 = rtime.exec(strCmdToRun1);
BufferedReader output = new BufferedReader(new InputStreamReader(
p1.getInputStream()));

}

Please let me know how i can pass integers to a shell script from java
# 2  
Old 04-15-2009
You need code like:
Code:
int result;
result = <whatever>
System.out.println(result);

The shell script executes the Java code like this:
Code:
result_from_java=`java your.Java.container`

Don't press your luck though. Java rarely should interact with a shell script in such a fashion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Remote login UNIX box from java passing parameters to the custom script called in the profile

Hello Good Day / Guten Tag.... I have to login the server and the user profile contains some scripts which need the inputs to be taken from the keyboard. So I use the method to conn.authenticateWithKeyboardInteractive(username, new InteractiveCallback() { public String... (1 Reply)
Discussion started by: Sanalkumaran
1 Replies

2. Shell Programming and Scripting

Passing Username & password through shell script to java code

Hi, I have a shell script (script.sh) in which we are calling java code which asks for Username: Password: for authentication purpose currently we are passing the credential manually and run the script. but I am trying echo -e "user_id\npassword" | script.sh but its not... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies

3. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

4. Shell Programming and Scripting

Grep float/integers but skip some integers

Hi, I am working in bash in Mac OSX, I have following 'input.txt' file: <INFO> HypoTestTool: >>> Done running HypoTestInverter on the workspace combined <INFO> HypoTestTool: The computed upper limit is: 11 +/- 1.02651 <INFO> HypoTestTool: expected limit (median) 11 <INFO> HypoTestTool: ... (13 Replies)
Discussion started by: Asif Siddique
13 Replies

5. Programming

Passing arguments from java to script shell

Hello Please i want to pass parameter (the string s) to the shell script: Quote: String s="Hello"; Process process = Runtime.getRuntime().exec("sh script1.sh"); How can i do please? Thank you (0 Replies)
Discussion started by: chercheur857
0 Replies

6. Shell Programming and Scripting

Passing argument from Java to Shell script

Hi All, I want to pass array of argument from Java to a shell script.I can use process builder api and its exec() method to call the script,but the question is how to receive the parameter in the script. Thanks in advance ---------- Post updated at 10:00 PM ---------- Previous update was... (1 Reply)
Discussion started by: Abhijeet_Atti
1 Replies

7. Shell Programming and Scripting

shell script that adds two integers and display answer on screen

please help shell script that adds two intergers and display answer on screen (1 Reply)
Discussion started by: wanyac2
1 Replies

8. UNIX for Dummies Questions & Answers

passing arguments from shell to java

Hi: I have a script called runjava: The content --- search=$1 dpi=$2 prefix=$3 input=$4 output=$5 java -Djava.library.path=./lib/path/Lib -classpath .:lib/path/Lib/mylib.jar myclass $search $dpi $prefix $input $output How does myclass parse arguments --- String searchTerm =... (3 Replies)
Discussion started by: kenpeter
3 Replies

9. Shell Programming and Scripting

Newbie Question: passing a variable into java from script?

I'm currently working on my second ever ksh script! So I apologize if this is a stupid question - I've searched the forum and on google and haven't seen anything :confused: I'm running my script with an input at startup that variable determines a couple of other values(int) that I store into... (1 Reply)
Discussion started by: Cailet
1 Replies

10. UNIX for Dummies Questions & Answers

how do you represent non integers in a shell script?

am trying to write a script that test that the load average which is taken from the uptime command's output to make sure it doesn't pass a certain limit. each time I execute the script, it complains about interger errors. if (2 Replies)
Discussion started by: TRUEST
2 Replies
Login or Register to Ask a Question