dcsimg
shell script in linux
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, June 23, 2003 04:49 AM

I want to create a user account in Java in linux platform. This program run on linux. I have tried: <! =========================================================== !> import java.io.IOException; import java.lang.Runtime; try { Process proc = Runtime.getRuntime().exec("adduser " + msg); }catch(IOException ex) { System.err.println("IOException: " + ex); ex.printStackTrace(); } <! =========================================================== !> But I execute the program, I got a error message "IOException: java.io.IOExceptio   More>>

I want to create a user account in Java in linux platform. This program run on linux.



I have tried:

<! =========================================================== !>



import java.io.IOException;

import java.lang.Runtime;



try {

Process proc = Runtime.getRuntime().exec("adduser " + msg);

}catch(IOException ex) {

System.err.println("IOException: " + ex);

ex.printStackTrace();

}



<! =========================================================== !>



But I execute the program, I got a error message
"IOException: java.io.IOException: adduser: not found
java.io.IOException: adduser: not found
at java.lang.UNIXProcess.forkAnExec(Native Method)
at java.lang.UNIXProcess.(init)(UNIXProcess.java:139)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:550)
at java.lang.Runtime.exec(Runtime.java:416)
at java.lang.Runtime.exec(Runtime.java:358)
at java.lang.Runtime.exec(Runtime.java:322)"



How can I solve this problem?



Thanks a lot!!!


   <<Less

Re: shell script in linux

Posted By:   Nick_Maiorano  
Posted On:   Monday, June 23, 2003 06:37 AM

Hello,



Your problem is one of 2 things:

1. adduser does not have execute privileges: All linux/unix shell scripts must have execute privileges. You can check by ls -l adduser. This command will list the file's privileges and make sure you see an "x" in the rwxrwxrwx string. If it's not there you can add it with chmod a+x adduser.

2. adduser is not on the PATH: When you fork a process from java, linux needs to locate the adduser file. Either you give it an absolute path in the java program or you add it to your PATH variable so that it can locate it. (PATH=/thepath/adduser:$PATH; export PATH)



That should do it.

About | Sitemap | Contact