Ricardo Vicente Fávero
Mon, 23 Oct 2000 03:52:42 -0700
|
Bom dia amigos da lista.
Estou tentando cadastrar usuários no linux via
servlets,veja o exemplo.......
String resultado =
"";
String User="adduser "+Conta+" -g 231 "; String Pass="passwd --stdin "+Conta; System.out.println("---> " + Pass); String TestErro=""; Runtime rt = Runtime.getRuntime(); try { Process process1 = rt.exec(User); InputStream in = process1.getErrorStream(); InputStreamReader inReader = new InputStreamReader(in); BufferedReader reader = new BufferedReader(inReader); String errorLine; TestErro = reader.readLine(); while((errorLine = reader.readLine()) != null) { System.out.println("---> " + errorLine); } } catch (IllegalArgumentException e) { System.out.println("Exception thrown: " + e); } catch(IOException e) { System.out.println("Exception thrown: " + e); } try { Process process2 = rt.exec(Pass); //???? InputStream in = process2.getErrorStream(); InputStreamReader inReader = new InputStreamReader(in); BufferedReader reader = new BufferedReader(inReader); String errorLine; while((errorLine = reader.readLine()) != null) { System.out.println("---> " + errorLine); } }
catch (IllegalArgumentException e) { System.out.println("Exception thrown: " + e); } catch(IOException e) { System.out.println("Exception thrown: " + e); } Para criar o conta, esta tudo ok, mais quando estou
criando a senha, o comando passwd tem subcomando, que é new unix password e
retype new unix password.
Como que eu faço para enviar mensagens para o
processo em execução??Ou ainda se alguém souber de um comando ou script que eu
informe em um mesmo comando o usuário e a senha para linux??
Agradeço a atenção de todos.
Ricardo Vicente Fávero
|