dimanche 19 juin 2016

pxssh will not allow the creation of the ssh -E logfile

pxssh will not allow the creation of the ssh -E logfile. But, log file creation works fine if executed from a shell. Could it be the underlying spawn command? What am I missing? (Python 3.2)

#!/usr/bin/env python

import sys

import pexpect
from pexpect import pxssh
import pprint

child = pxssh.pxssh(timeout=5)

print("using ssh: %s" % (pexpect.which("ssh")))

child.SSH_OPTS += " -o'LogLevel=DEBUG3'"
child.SSH_OPTS += " -E /tmp/my_logfile.log"
print("The Child's NEW SSH_OPTS")
pprint.pprint(child.SSH_OPTS)

child.login('my_thing', 'my_username', 'my_password', auto_prompt_reset=False, quiet=False)

child.sync_original_prompt()

child.sendline('pwd')
child.prompt()
print("child.before <%s>" % (child.before.decode('utf-8')))

sys.exit()

Here's what it does:

tcsh-58: python3 /tmp/demo_pxssh.py
using ssh: /volume/my_dir/openssh-7.2p2/ssh
The Child's NEW SSH_OPTS
"-o'RSAAuthentication=no' -o 'PubkeyAuthentication=no' -o'LogLevel=DEBUG3' -E /tmp/my_logfile.log"
child.before <1: 2016-05-26 03:23:45 UTC
pwd
/var/home/my_dir
% >

tcsh-59: ls -al  /tmp/my_logfile.log
ls: cannot access /tmp/my_logfile.log: No such file or directory

But if I do the same basic thing manually, it WORKS:

tcsh-60: which ssh
/volume/my_dir/openssh-7.2p2/ssh

tcsh-61: ssh -E /tmp/my_logfile my_username@my_thing
Password:
Last login: Fri Jun 17 22:29:02 2016 from 192.168.70.133
--- MyOS xx.xx.rev ... (kernel) #1: 2016-05-26 03:23:45 UTC
% exit
logout
Connection to my_thing closed.
tcsh-62: ls -alt /tmp/my_logfile
-rw------- 1 my_userid my_gid 230 Jun 17 22:30 /tmp/my_logfile

So.. Why can't I create a log file under pxssh... But, clearly with the same command (from the same directory), it will not create a log file.

Aucun commentaire:

Enregistrer un commentaire