1

I have a simple paramiko script that connects to a server and executes a command:

command = "cd /path/to/command_file; sh command;"

stdin, stdout, stderr = ssh.exec_command(command)
stdin.write('test')

lines = stdout.readlines()
print(lines)

ssh.close()

That command file executes some things I don't understand much (separated in lines for readability):

/path/to/hex_file/hex -h 35 
                      -cpterm iso8859-1 
                      -cpstream ibm850 
                      -pf /path/to/databases_list/database_list.pf 
                      -p another_file.p                                 <--- changed to '-b another_file.p' later

When it's executed, it returns:

Redirection or piping of stdin or stdout is allowed only with -b.

And when it's changed to -b, it returns:

Batch-mode X requires a startup procedure.

There's any idea to where I can start search for that procedure? Or there's any way to permit piping of stdin?

ThRnk
  • 575
  • 2
  • 19

1 Answers1

0

Batch-mode X requires a startup procedure.

Your question is more about your /path/to/hex_file/hex program. Which seems to be something proprietary. We cannot help you with that. Contact the program vendor.


The only thing I can suggest for your Python code is to enable a pseudo terminal using get_pty parameter, what might workaround the problem:

stdin, stdout, stderr = ssh.exec_command(command, get_pty=True)

But I do not recommend that, as it can bring you other undesired side effects.

For a similar problem, see Getting "must be run from a terminal" when switching to root user using Paramiko module in Python.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992