By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Running Command Line Scripts From Java

P: n/a
I'm having trouble with a bash script (in Linux) I'm running from Java. It
works -- some of the time, but I can't determine exactly why it works 1
time and doesn't work the next 4-5 times.

I'm not sure, but the script seems more likely to work if I run it directly
from bash. I was thinking of running a small script and, within the
script, calling bash directly to execute the program, something like:

#!/bin/bash
bash /usr/local/myprog/setup

I know Java runs the command on its own, so it isn't using bash or any other
shell. Will this force my setup program to be run under bash? Are there
any side effects or considerations that might not be obvious to a
self-taught coder?

Thanks for any insight or feedback on this problem!

Hal
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hal Vaughan <ha*@thresholddigital.com> wrote in message news:<gB09c.12741$JO3.20875@attbi_s04>...
I'm having trouble with a bash script (in Linux) I'm running from Java. It
works -- some of the time, but I can't determine exactly why it works 1
time and doesn't work the next 4-5 times.

I'm not sure, but the script seems more likely to work if I run it directly
from bash. I was thinking of running a small script and, within the
script, calling bash directly to execute the program, something like:

#!/bin/bash
bash /usr/local/myprog/setup

I know Java runs the command on its own, so it isn't using bash or any other
shell. Will this force my setup program to be run under bash? Are there
any side effects or considerations that might not be obvious to a
self-taught coder?

Thanks for any insight or feedback on this problem!

Hal


Runtime.getRuntime().exec(new String[] {"/bin\sh", "-c", "myscript"});
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.