LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-03-2009, 09:05 PM   #1
Sunday03
LQ Newbie
 
Registered: Feb 2009
Posts: 20

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


Hi,

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[]
2)"/bin/sh"
3)"-c"

do in the command?

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

Rep: Reputation: 19
Hi
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.

Mark
 
  


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
Runtime.getRuntime().exec("cd") returns java.io.IOException, 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


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

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