LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2009, 04:11 AM   #1
kulandaivelu
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
Smile how to use bash command in java?


Hi,

when i run the following code, 'test.sh' not started


================================================================

String cmd = "bash \"/home/kulandaivelu/Desktop/works/other's works/test.sh\"";
Runtime.getRuntime().exec(cmd).waitFor();

================================================================


but it started when i use same command(bash "/home/kulandaivelu/Desktop/works/other's works/test.sh") in terminal

anyone let me know what mistake i made in the code piece..

Thanks in Advance
Kulandaivelu
 
Old 03-18-2009, 04:57 AM   #2
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 67
http://www.java-tips.org/java-se-tip...ssbuilder.html
 
Old 03-18-2009, 07:49 AM   #3
kulandaivelu
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Hi almatic,

Thank you for reply..

first of all i am sorry for posted the wrong question in this forum

actually this question should be asked in the java forum

anyhow i got a answer for above question

i changed the code as like below. it worked well.


===============================================================

String cmd[] = {"bash","/home/kulandaivelu/Desktop/works other's/test.sh"};

Runtime.getRuntime().exec(cmd).waitFor();

===============================================================


Thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
java -version, bash: java: command not found kirman Programming 4 03-19-2008 11:13 PM
-bash: java: command not found vinbase Linux - Newbie 1 01-01-2008 05:52 PM
(Debian) bash: java: command not found pjpeter Linux - Newbie 3 09-25-2004 02:59 PM
bash: java: command not found pjpeter Programming 4 09-24-2004 03:02 PM
java command - "bash: java: command not found" ??? RedHat123 Programming 2 07-16-2002 11:09 PM


All times are GMT -5. The time now is 09:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration