Jose Velasquez

Generation

generate functionSat, 17 Jun 2023

enviar contraseña y escribirla automaticamente en el prompt de linux

import os import sys import subprocess def write_password(): # get the password password = input("Enter your password: ") # get the command to the terminal command = 'echo ' + password + ' | sudo -S ' + sys.argv[1] # execute the command p = subprocess.Popen(command, shell=True) os.waitpid(p.pid, 0) # print the return print(p.returncode) if __name__ == "__main__": write_password()

Want to kickstart your project?Use the new AI Studio to create your code