How to comfirm automatically when execute a command with python script in centos?
For example,
there is a command below,it has a confirmation step:
[root@vagrant-prod ~]# php artisan key:generate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Now I want to execute above command via a python script:
auto.py
#!/usr/bin/python3
import os
def regenerate_key():
os.system('cd /var/www/laravel_blog && php artisan key:generate')
if __name__ == "__main__":
regenerate_key()
Executing above auto.py
:
[root@vagrant-prod ~]# python3 auto.py
It also need to input yes
manually,I want to comfirm it with above python script,how to do it?
update:
[root@vagrant-prod laravel_blog]# yes yes | php artisan key:generate
**************************************
* Application In Production! *
**************************************
Command Cancelled!
One yes or two yes
s have the same result.