I need to send the command iperf -s to a Linux server using a Python program. The command is not sent. The chronology of problems is as follows:
- I am sending the command
iperf -s
to the server. Nothing happens, the program freezes (I don’t stop the program). - I use the
netstat -tupln
to check the processes. A processiperf
is created on the server, but nothing is happened. - If I kill this process with a
sudo kill -9 <PID>
, the program outputs the traditional output when theiperf -s
is executed and the program exits. - If I check the processes again, the
iperf
process is not there.
Here’s my code:
remote_server = "172.22.94.171"
client = paramiko.client.SSHClient()
username = "useruser"
password = "password"
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(remote_server, port=22, username=username, password=password)
stdin, stdout, stderr = client.exec_command('sudo iperf -s', get_pty=True)
stdin.write(password+'\n')
print(stdout.readlines())