0

I have a python script that launches a bunch of commands via ssh

ins = []
outs = []
errs = []
for sourceId in range(N):
    fname = WE.current_path + "/DATA/fsismos_P" + format(sourceId, '04d')
    cmd = "sustrip < " + fname + "_addnoise.su head=" + fname + ".headers > " + fname + "_addnoise"
    stdin, stdout, stderr = ssh_client.exec_command(cmd)
    print(cmd)
    outs.append(stdout)
    errs.append(stderr)
for out in outs:
    out.channel.recv_exit_status()
for err in errs:
    err.channel.recv_exit_status()
    print(err.read().decode('ascii').strip('\n'))

The command fails and returns a

sustrip: subcalls.c: efopen: fopen failed

However, when I manually connect onto the server and type the command it works perfectly fine. How is that possible ?

  • 1
    Can you run the command as `ssh user@client "sustrip < xxx_addnoise.su head=xxx.headers > xxx_addnoise"`? I'm wondering if there's something about a non-interactive shell that's biting you. Maybe some bashrc thing that's not being done. – Tim Roberts Apr 06 '21 at 21:31
  • indeed ssh user@client "sustrip < xxx_addnoise.su head=xxx.headers > xxx_addnoise" do not work. Thanks – Alexandre Hoffmann Apr 07 '21 at 05:57
  • I do not know the tool your are trying to execute. Nor does the error mean anything to me. But in general @Tim is probably right. This will be related to non-interactive shell. See [Some Unix commands fail with “ not found”, when executed using Python Paramiko exec_command](https://stackoverflow.com/q/55419330/850848). – Martin Prikryl Apr 07 '21 at 06:50
  • Yes it was that I solved this by adding get_pty=True – Alexandre Hoffmann Apr 07 '21 at 10:00

0 Answers0