LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Restart PADS from Java Program (https://www.linuxquestions.org/questions/linux-newbie-8/restart-pads-from-java-program-818501/)

khirodpatra 07-07-2010 09:37 AM

Restart PADS from Java Program
 
Hi,

I am facing problems to restart PADS(Passive asset detection system) from java program.I used the root as a user. So from the command prompt I can start PADS with out sudo ,but when I try to start PADS from the my java program i.e.

Process proc=Runtime.getRuntime().exec("pads restart");

It throws the error in log that FATAL error ! you not root
and permission denied.

Then I tried the same with sudo

Process proc=Runtime.getRuntime().exec("sudo pads restart";

Here it create another two process extra
1 for stop the pads
2) for start the pads

It does not kill the previous process of PADS .and both the process get hung.

Please help me how I can solve this , that will work same in both from terminal and the java program


Regards
Khirod Patra

jlanawalt 07-15-2010 01:08 AM

Breaking it down
 
Take your problem and break it down into pieces:
  • Call a program from Java
  • Call a program with arguments from Java
  • Call a suexec root program from Java
  • Call a program via sudo from Java
  • Verify your restart command from the command line, then implement that in Java

Doing this can help you determine if it's a PADS issue, or inexperience with the Runtime.getRuntime().exec(...) method--which looks like a mix of the system and exec C calls--, or with your restart command. Divide and conquer, write small test cases, keep it simple.


All times are GMT -5. The time now is 01:44 PM.