I have a simple script (child.py
) as below:
#!/usr/bin/env python
import pexpect
def ency():
child = pexpect.spawn("cryptsetup luksChangeKey /mnt/ency")
child.expect('Enter passphrase to be changed:')
child.sendline('password-old')
child.expect('Enter .*: ')
child.sendline('password-new')
child.expect('Verify .*: ')
child.sendline('password-new')
child.interact()
ency()
I invoke this script using a different script (master.sh
)
#!/bin/bash
python child.py
The code run successfully when I run child.py
, but when I envoke child.py
using master.sh
, I get the following error:
Traceback (most recent call last):
File "child.py", line 15, in <module>
ency()
File "child.py", line 13, in ency
child.interact()
File "/usr/lib/python2.7/site-packages/pexpect-4.2.1-py2.7.egg/pexpect/pty_spawn.py", line 740, in interact
mode = tty.tcgetattr(self.STDIN_FILENO)
termios.error: (25, 'Inappropriate ioctl for device')
Note that I am invoking master.sh
using PowerCLI. I also tried to invoke child.py
directly using PowerCLI's Invoke-vmscript –vm vmname –scripttext “python child.py”
and still get the same behavior.
Any ideas or suggestions on how to resolve this?
Thanks
Since you are running the
pexpect
script on a VM I suppose you don't really need tointeract
with it. So just replacewith
to wait for the child to complete.
According to the doc,
interact()