1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 06:47:54 +02:00

[shutit/en] shutit added (#2754)

This commit is contained in:
Ian Miell
2017-06-09 17:18:53 +01:00
committed by ven
parent fe63139343
commit 8d78277bbc

View File

@@ -36,7 +36,7 @@ python example.py
outputs: outputs:
```bash ```bash
python example.py $ python example.py
echo "Hello World" echo "Hello World"
echo "Hello World" echo "Hello World"
Hello World Hello World
@@ -67,6 +67,7 @@ which will log you into your server (if you replace with your details) and
output the hostname. output the hostname.
``` ```
$ python example.py
hostname hostname
hostname hostname
example.com example.com
@@ -87,6 +88,7 @@ session.logout()
which forces you to input the password: which forces you to input the password:
``` ```
$ python example.py
Input Secret: Input Secret:
hostname hostname
hostname hostname
@@ -162,7 +164,7 @@ session1.logout()
session2.logout() session2.logout()
``` ```
Here you use the 'send_and_get_output' method to retrieve the output of the Here you use the 'send\_and\_get\_output' method to retrieve the output of the
capacity command (df). capacity command (df).
There are much more elegant ways to do the above (eg have a dictionary of the There are much more elegant ways to do the above (eg have a dictionary of the
@@ -187,7 +189,7 @@ session.logout()
Note the 'expect' argument. You only need to give a subset of telnet's Note the 'expect' argument. You only need to give a subset of telnet's
prompt to match and continue. prompt to match and continue.
Note also the 'check_exit' argument in the above, which is new. We'll come back Note also the 'check\_exit' argument in the above, which is new. We'll come back
to that. The output of the above is: to that. The output of the above is:
```bash ```bash
@@ -217,8 +219,8 @@ here
Connection closed by foreign host. Connection closed by foreign host.
``` ```
Now back to 'check_exit=False'. Since the telnet command returns a failure exit Now back to 'check\_exit=False'. Since the telnet command returns a failure exit
code (1) and we don't want the script to fail, you set 'check_exit=False' to code (1) and we don't want the script to fail, you set 'check\_exit=False' to
let ShutIt know you don't care about the exit code. let ShutIt know you don't care about the exit code.
If you didn't pass that argument in, ShutIt gives you an interactive terminal If you didn't pass that argument in, ShutIt gives you an interactive terminal