0

hi everyone,
im trying to run a linux script in java where it ask the user to input a password,then when suucessfully executed it prompts the user to enter the same password for verification,how can i do this in java,im using trilead to remotely access and execute command,im having problem when sending the password for verification.
im using sess.startshell();

thanks,any help will be much appreciated

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by ebok
0

thanks,
but im using trilead,actually i can execute command as an su,but my problem is that when it prompts me for password again,it call a blank password eve i havent enter anything.any idea on how to do this..this is my code

sess=conn.openSession();
sess.requestDumbPTY();


if (Restart.equals("integration")) {
BufferedOutputStream  stdin = new BufferedOutputStream(sess.getStdin());
sess.startShell();


InputStream stdout = sess.getStdout();
InputStream stderr = sess.getStderr();


stdin.write(("su - postgres -c \"/etc/init.d/postgresql restart\"" + "\n").getBytes());
stdin.write((root_pass + "\n").getBytes());
stdout.read();
stdin.flush();
stdin.write((root_pass + "\n").getBytes());
stdin.flush();

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.