linux(centos 6):
step 1
$:yum install xxx
reture some message like
"Are you OK with your IP being logged? (Y)es/(N)o"
step 2
$:Y
the install is going on.(other commands maybe have step 3)
but how can i execute this cammands with java?
this is my java code:
String[] commands = new String[]{"yum","install","xxx"};
Runtime run = Runtime.getRuntime();
Process pr = run.exec(commands);
Reader reader = new InputStreamReader(pr.getInputStream());
BufferedReader bf = new BufferedReader(reader);
the bf include
"Are you OK with your IP being logged?"
Now how can i execute the command( "Y"
) so that the install can going on
please help me.
I don't know how you can execute the command with a "y" (Yes) but instead you could run yum as follows
yum -y install xxx
-y, --assumeyes Assume yes; assume that the answer to any question which would be asked is yes. Configuration Option: assumeyes See: https://linux.die.net/man/8/yum
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.