Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-03-2009, 09:05 PM   #1
LQ Newbie
Registered: Feb 2009
Posts: 20

Rep: Reputation: 0
Smile Runtime.getRuntime().exec()


I would like to know
what does the following line do...

Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", "echo \"[" + userid + "]\" >> /../*.conf"});

I understand 'echo' command.
But what do
1)new String[]

do in the command?

Thanks in advance.
Old 03-05-2009, 06:51 AM   #2
Registered: Feb 2009
Location: Mayo, Ireland
Distribution: LFS 6.4; Debian 5.4; Mythbuntu & Kubuntu 10.04
Posts: 49

Rep: Reputation: 19
new String[] creates a new array (or collection) of strings.

Each comma seperated value in {"/bin/sh","-c" ... is one element in the array, these are processed sequentially be exec

/bin/sh is the first statement to be processed and sets up the correct environment for the rest of the elements.
/bin/sh is a default shell/terminal for executing commands, similar to a dos prompt in windows. Unlike a generic Dos prompt, most linux distributions include different shells (e.g. bash) with slightly dfferent features and semantics.



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
Runtime.getRuntime().exec("cd") returns, error 2 in java tatarin Programming 4 03-28-2008 08:42 PM
development or runtime maooah Linux - Server 2 01-28-2008 12:31 AM
exec cmd=perl... work but exec cgi doenst crions Slackware 5 12-09-2005 01:17 PM
java runtime() exec() program mcshen Programming 4 11-25-2004 12:29 PM
Runtime.getRuntime().exec("javac ") ihasircioglu Programming 1 05-27-2004 07:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:02 PM.

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