-1

I'm novice in Python scripting. trying to redirect stdout/stderr into file. python script is running on remote machine. doing something like below:

stdin, stdout, stderr = ssh.exec_command(remotePath + proto)
rc = stdout.channel.recv_exit_status()
sys.stdout=open('erroLog', 'w')
bay
  • 109
  • 3
  • 10

2 Answers2

0

If you have access to the terminal, try using the shell redirection method:

$ python foo.py > output.txt

The last line of your pasted code is correct and should be writing an erroLog file. Perhaps the server permissions are set wrong and the script does not have write access to create a file?

Jacob Bridges
  • 725
  • 2
  • 8
  • 16
0

Assuming you store your error in a variable

output=open(erroLog, "w")
output.write (variable)
repzero
  • 8,254
  • 2
  • 18
  • 40