https://github.com/xmonader/expectless
Simple expect library for python
https://github.com/xmonader/expectless
automation expect pexpect python3 sysadmin
Last synced: 12 months ago
JSON representation
Simple expect library for python
- Host: GitHub
- URL: https://github.com/xmonader/expectless
- Owner: xmonader
- License: mit
- Created: 2017-06-03T13:52:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-18T16:01:17.000Z (about 9 years ago)
- Last Synced: 2025-06-21T14:39:17.064Z (about 1 year ago)
- Topics: automation, expect, pexpect, python3, sysadmin
- Language: Python
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# expectless
Simple expect library for python
## Usage
we have a script called `test_expect.py` which asks the user for a name and a password to continue. you can easily automate that by creating `expectations list` like the following
```
expectations = [
('name:', 'ahmed'),
('password:', 'ahardpassword'),
]
```
and then invoke the script
```
p = expect(["./test_expect.py"], expectations=expectations)
```
You can also use networked applications as well for instance talking to ssh on a remote machine
```python
p = expect(["ssh", "-T", "mie@10.147.19.169", "ls /home"], expectations=[("mie@10.147.19.169's password:", 'apa')])
```
## Interactivity
You can interact with the application
```
p = expect(["python3"])
interact(p[0])
```
## expectless In action
[](https://asciinema.org/a/2uek7k78ldtfw6s0as15dtepd)
## But why?
I wanted to learn about PTYs `Pseudoterminal` and I always liked `expect` tool
## Next steps:
- Regular expressions expectations.
## Operating systems support?
It's only developed and tested on GNU/Linux operating system, and I've no idea about other operating systems. PRs are welcome.