An open API service indexing awesome lists of open source software.

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

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
[![asciicast](https://asciinema.org/a/2uek7k78ldtfw6s0as15dtepd.png)](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.