Run commmands interactively using icommandlib or pexpect
However, if the command you want to run requires that:
- It prompts the user for a response (yes or no / password / etc.)
- It 'draws' on a terminal window - like 'top'.
- You want to interact with the process and do other stuff while it runs (e.g. wait for a database service to warm up and then continue).
Then you need an interactive library.
The two examples below are not actually interactive but they demonstrate how pexpect and icommandlib can be used.
#!/bin/bash echo hello $1
from commandlib import Command
process = Command("./outputtext", "mark").interactive().run() process.wait_until_output_contains("mark") process.wait_for_successful_exit()
from pexpect import EOF process = Command("./outputtext", "mark").pexpect() process.expect("mark") process.expect(EOF) process.close()
Documentation automatically generated from icommand-or-pexpect.story storytests.