Problem while Invoke Shell Script function from Java Program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while Invoke Shell Script function from Java Program
# 1  
Old 11-22-2012
Problem while Invoke Shell Script function from Java Program

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  
Old 11-22-2012
Have you called that function in your shell script?
# 3  
Old 11-22-2012
Quote:
Originally Posted by pamu
Have you called that function in your shell script?
yes. i have called that function. while running in Konsole i got the output. But when invoke through Java Program. Only function not get executed. other things are working.



Code:
 #!/bin/bash

echo "Test shell script"

function checkfunction() 
{
  echo "hey!  shell script function called"
}

checkfunction


when i execute the above program in local/terminal. i got the output:
Test shell script
hey! shell script function called


NOTE:
When i invoke the above shell script from java using the code
Code:
Runtime.getRuntime().exec(filename.sh) ;


i got the output:
Test shell script


Here the problem is, the function in shell script is not invoked.


whether i have to export the functions?
Please Suggest me, how to solve this problem.


Regards,
Nanthagopal A

Thank You

Last edited by nanthagopal; 12-07-2012 at 01:58 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing the shell script through java program

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)
Discussion started by: punpun777777
2 Replies

2. Shell Programming and Scripting

Shell script to input as if from command line to the java program

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

3. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: aish11
4 Replies

4. Shell Programming and Scripting

Script of invoke an email program

Is it possible that a shell script invokes a windows mailing application like Lotus Notes and creates a mail and sends it ? (2 Replies)
Discussion started by: csrohit
2 Replies

5. UNIX for Advanced & Expert Users

Invoke unix script using c program

hi i want to invoke a unix script in a C program and also return some value from the script to the C program to use that value further. Basically i am doing a Lookup operation in this unix script and returning the looked up data from a oracle database table.. please help me invoke as well... (1 Reply)
Discussion started by: somi2yoga
1 Replies

6. Solaris

How to invoke remote java program from ssh

How can i invoke java program from MC1, when I connect remotely to execute can I set classpath etc. ____________ <-------------->____________________ |..................|<-------------->|...............................| |..................|<-------------->|...............................|... (2 Replies)
Discussion started by: vishnu559
2 Replies

7. Shell Programming and Scripting

Problem with a function in a shell script

Hi, I am trying to write a function in the shell script . This function accepts two parameters. It is as following: set_cache(i_SEQ_NAME,I_cache_size) { _sqlplus "BEGIN alter_seq_cache(i_SEQ_NAME, I_cache_size); END;" } _sqlplus is another function and has been working working.... (3 Replies)
Discussion started by: neeto
3 Replies

8. Shell Programming and Scripting

How to invoke a perl script from java program

Hi: I need to invoke a perl script from a java applet program in UNIX operating system.. Can you please suggest me!!! (4 Replies)
Discussion started by: grajesh_955
4 Replies

9. Shell Programming and Scripting

Invoke java program in script

Hey all, My boss tasked me with the job to write a script which would invoke various java programs, the thing is I don't know much about shell scripting so would you experts help me out? Here is the requirement - 2 applications written in java: App_A and App_B -... (0 Replies)
Discussion started by: mpang_
0 Replies

10. UNIX for Advanced & Expert Users

Invoke java program in different processc d

I have a simple script like this: for file in $dodfiles; do ./rundod $file done $dodfiles is an array of file names selected rundod is a script which invokes a java progrm which process a data file all the processing message logged into a log file in order to extract and analyze the... (1 Reply)
Discussion started by: liux99
1 Replies
Login or Register to Ask a Question