Disable pagination on the command line
Question: I am trying to write a script using the python module `pexpect` that will
connect to a server and execute commands like you are typing at the command
line.

So for example, you can have something like:

`child = pexpect.spawn('/usr/bin/ssh user@example.com')`

`child.sendLine('ls -al')`

or whatever command you want to send. It will act like you are typing in a
terminal.

In my script, I am trying to run a command using the `sendLine()` API that
essentially dumps out a bunch of info to the command line. But there is a
pagination that requires there to be another command where you have to press a
key to continue to get to the next command.

So for example:

`[Some info]`

`--------------- To continue, press any key. To quit, press 'q'.
---------------`

`[Some more info]`

Is there a way that I can turn pagination off or a command I can send before I
try to dump the info to the command line to turn it off?


Answer: **In Linux:** You can use redirection to skip the pager(`more` or `less`). If
it is important to display the output on screen, the output can be redirected
to `tee`.

For example in `man ls; ls`, the `man` command expects the user to press `q` for termination and then `ls` is executed. To execute both the commands simultaneously without user intervention, it can be done as `man ls | tee; ls`. If displaying the output is not mandatory, it can be redirected to `/dev/null` as well.

For additional help, please specify the exact command that you are trying to
execute on the remote server.

**In Python:** When using `pexpect`, the user activity can be automated if the
intermediate output is known in advance. You can use `expect` function to wait
for a particular output and then take necessary action(for example using
`sendLine`).

