Last active
June 19, 2024 01:17
-
-
Save LukeDRussell/1094ab558eb763f2aaedc9d67041b678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from netmiko import ConnectHandler | |
#### Logging | |
# import logging | |
# logging.basicConfig(filename="netmiko.log", level=logging.DEBUG) | |
# logger = logging.getLogger("netmiko") | |
#### Logging | |
connection = { | |
"device_type": "checkpoint_gaia", | |
"host": "gaia", # VM Gaia R81.10 | |
"username": "admin", | |
"password": "Password1", | |
# "session_log": "gaia1.log" | |
} | |
with ConnectHandler(**connection) as cli: | |
print(cli.find_prompt()) | |
users = cli.send_command("show users") | |
print(f"show users:\n {users}") | |
Result second time:
gw-bbd539> set clienv rows 0
show users:
gw-bbd539>
gw-bbd539>
show users:
gw-bbd539>
Result when running directly from device in an interactive terminal:
gw-bbd539> show users
User Uid Gid Home Dir. Shell Real Name Privileges
admin 0 0 /home/admin /etc/cli.sh Admin Access to Expert features
monitor 102 100 /home/monitor /etc/cli.sh Monitor None
gw-bbd539>
This seems pretty reliable.
import time
from netmiko import ConnectHandler
connection = {
"device_type": "checkpoint_gaia",
"host": "gaia", # VM Gaia R81.10
"username": "admin",
"password": "Password1",
}
gaia_expect = r"[>#]"
with ConnectHandler(**connection) as cli:
time.sleep(1)
show_web_daemon = cli.send_command("show web daemon-enable", expect_string=gaia_expect)
if " on" in show_web_daemon:
web_enabled = True
else:
web_enabled = False
print(web_enabled)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result first time: