pexpect

How to automate shell interactive commands using Python pexpect module

淺唱寂寞╮ 提交于 2021-01-28 05:05:24
问题 I am trying to automate the setup of an application by performing SSH to the machine and goto /var/packages folder and execute the script.when the installation starts a set of interactive commands to be send based on the expected output.I found from google that pexpect can achieve this but i am unable to achieve the result that i wish. I am trying following code , can someone guide me how to achieve this as I am beginner to python.Any help would be appreciated. My application setup would look

Switch between interactive and non-interactive mode in pexpect

て烟熏妆下的殇ゞ 提交于 2021-01-02 04:04:12
问题 I am using pexpect to upload a file to SFTP server. For accesssing the server first time, I get message as The authenticity of host..can't be established.Are you sure you want to continue connecting (yes/no)? to which I want the user to interact and answer yes/no. However, when user says yes, I want the interactive mode to be off and then take the password from my script instead of prompting user. Is this possible using pexpect ? p = spawn('XXXXXXXX') password = 'XXXXXXXXx' out=p.expect(['(?i

Switch between interactive and non-interactive mode in pexpect

泪湿孤枕 提交于 2021-01-02 04:03:43
问题 I am using pexpect to upload a file to SFTP server. For accesssing the server first time, I get message as The authenticity of host..can't be established.Are you sure you want to continue connecting (yes/no)? to which I want the user to interact and answer yes/no. However, when user says yes, I want the interactive mode to be off and then take the password from my script instead of prompting user. Is this possible using pexpect ? p = spawn('XXXXXXXX') password = 'XXXXXXXXx' out=p.expect(['(?i