Wednesday, January 9, 2013

How do i connect to the Linux command prompt using JAVA code?

Q. Hmm... not sure if u understand wat i mean....
What i want to know is the codes in JAVA to run the things in Linux command prompt... Like when i run the java prog, i want to be able to connect to the command prompt ... (hope u understand... :P)
Thanks a lot... =)

PS: Any useful links will be really appreciated =)

A. I think I know what your trying to say. You want to run a linux command from the the Java Runtime Environment. This command should work.
Runtime.getRuntime().exec(String command);
There is more info at this link http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=34&t=003535.

What is the linux command to obtain the PID number of a specific program running?
Q. I'm tired to use the "top" and search around for the PID of a program that I know is running on a remote terminal, left open by someone else, and that I want to kill. I wonder if there is a linux command that would return the PID of only that program.

A. ps aux | grep processname
or
pidof processname

How to enter password by linux command?
Q. As the title.I would like to find out How to enter password by linux command?

eg: when you write a script to sudo root. then you will be asked to enter password.
how can i do it by linux script? Is there a command can do the job?
Thanks in advance.

A. Don't. just run sudo script instead of trying to put sudo into the script.




Powered by Yahoo! Answers

No comments:

Post a Comment