単純な pexpect スクリプトを使用して、リモート マシンに ssh し、コマンドによって返された値を取得しています。UNIXの挨拶を無視するために使用できるpexpectまたはsshwiseの方法はありますか? つまり、から
child = pexpect.spawn('/usr/bin/ssh %s@%s' % (rem_user, host))
child.expect('[pP]assword: ', timeout=5)
child.sendline(spass)
child.expect([pexpect.TIMEOUT, prompt])
child.before = '0'
child.sendline ('%s' % cmd2exec)
child.expect([pexpect.EOF, prompt])
# Collected data processing
result = child.before
# logon to the machine returns a lot of garbage, the returned executed command is at the 57th position
print result.split('\r\n') [57]
result = result.split('\r\n') [57]
「最後に成功したログイン」と「(c)著作権」を無視して、値の正しい位置を気にすることなく、戻り値を取得するにはどうすればよいですか?
ありがとう !