If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Passing argument from java to shell script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-03, 00:17
prasanthik83 prasanthik83 is offline
Registered User
 
Join Date: Dec 2003
Posts: 20
Passing argument from java to shell script

Hi

I am trying to call shell script from java program.I tried it using
Process p=Runtime.getRuntime().exec("filename.sh");
Along with the filename,i want to pass parameters to the shell script. How to do this???

Waiting for ur quick reply.
Thanks in advance,
Bye
Prasanthi
Reply With Quote
  #2 (permalink)  
Old 12-16-03, 00:41
pooja pooja is offline
Registered User
 
Join Date: Dec 2002
Posts: 104
Re: Passing argument from java to shell script

Quote:
Originally posted by prasanthik83
Hi

I am trying to call shell script from java program.I tried it using
Process p=Runtime.getRuntime().exec("filename.sh");
Along with the filename,i want to pass parameters to the shell script. How to do this???

Waiting for ur quick reply.
Thanks in advance,
Bye
Prasanthi
hi,

i have no idea about java, but its just a thought.

did u tried Process p=Runtime.getRuntime().exec("filename.sh param1 param2");


--pooja
Reply With Quote
  #3 (permalink)  
Old 12-16-03, 01:37
prasanthik83 prasanthik83 is offline
Registered User
 
Join Date: Dec 2003
Posts: 20
Hi pooja !

Thank u very much for your solution. I tried it and got the solution.

Bye
Prasanthi
Reply With Quote
  #4 (permalink)  
Old 12-16-03, 07:13
prasanthik83 prasanthik83 is offline
Registered User
 
Join Date: Dec 2003
Posts: 20
Hi !
I am trying to send a variable to shell script from java.
i.e txtstr="xxx"
Process p=Runtime.getRuntime().exec("filename.sh 'txtstr'");
But it is taking argument as a txtxstr but not its value.
How to solve this?????

Thanks in advance,
Waiting for ur reply,
Bye
Prasanthi
Reply With Quote
  #5 (permalink)  
Old 12-16-03, 09:29
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
Like this?

Process p=Runtime.getRuntime().exec("filename.sh " txtstr);
Reply With Quote
  #6 (permalink)  
Old 03-12-04, 08:47
jawednazarali jawednazarali is offline
Registered User
 
Join Date: Mar 2004
Posts: 1
Re: Passing argument from java to shell script

make an array of String and pass it to exec() for e.g
i want to use Net Send command from java:

String params={"NET","SEND","COMPUTER/USER ID","Your Message"};

Process p=Runtime.getRuntime().exec(params);


can you plz send me the code how you have invoked the shell script on my email: maknojia@gem.net.pk
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On