PHP ssh2_exec answering to prompt questions
I must use ssh2_exec to install some packages on linux servers. Some of the packages require some answers when installing so I must be able to provide those answers using the ssh2_exec function from PHP. I already know the answers to those questions but it's hard to enter the response when the question is prompted. Example:
// Build command for OpenVPN
ssh2_exec ( $connection, "./build-ca" );
The above command wi开发者_Python百科ll trigger openvpn to be configured so it asks a few questions such as:
Country Name (2 letter code) [US]:
For the above question I must answer "US" and hit enter to continue etc. Any ideas how to do this using ssh2_exec function?
The only clean solution is not executing programs expecting user input. Check if build.ca has a config file where you can give default values and if yes, upload a such a file via SCP and then execute build-ca so it uses these values.
精彩评论