Файл .py:
Код: Выделить всё
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, password=password)
print("Connected")
stdin, stdout, stderr = ssh.exec_command(myscript)
# read the standard output and print it
print(stdout.read().decode())
# print errors if there are any
err = stderr.read().decode()
if err:
print(err)
ssh.close()
Код: Выделить всё
cd /usr/data
pwd
read -r username
echo "$username"
Код: Выделить всё
/usr/data
Как я могу добиться этого с помощью Python (pycharm ide) и Unix?>
Мобильная версия