0

the following code updates a database on a remote server:

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(ssh_config['hostname'], username=ssh_config['user'], port=ssh_config['port'], key_filename=ssh_config['identityfile'][0])
    stdin, stdout, stderr = client.exec_command(f'psql -U {dbuser} {db} < {targetfile}')
    print(stdout.channel.recv_exit_status())
    client.close()

This works fine, unless I remove the print statement – without it, the database is never updated. I guess that the command is not executed unless I request its exit status – why is that, and how can I force the command execution without referring to the exit code?

Thanks, Jan

janeden
  • 329
  • 2
  • 10
  • That's as expected: [Wait until task is completed on Remote Machine through Python](https://stackoverflow.com/q/28485647/850848) – This looks like [XY problem](https://meta.stackexchange.com/q/66377/218578). What's wrong with what you are doing currently? – Martin Prikryl May 01 '22 at 17:23

0 Answers0