예제 #1
0
else:
    LOG = 0

try:
    fd = open("devices.txt", "r")
except:
    print(Fore.RED + "File devices.txt not found!")
    print(Style.RESET_ALL)
    sys.exit(1)

USER = input("Enter username: "******"Enter password: "******"not found or not reachable via ICMP!")
        print(Style.RESET_ALL)
    else:

        if (LOG == 1):
            try:
                log_file = open(HOST + ".log", "w")
            except:
                print(Fore.RED + "Failed creating log file!")
                print(Style.RESET_ALL)
                sys.exit(1)

        try:
            fc = open("comandos.txt", "r")
        except:
예제 #2
0
from getpass import getpass
import ip_functions

#logging.basicConfig(filename='test.log', level=logging.DEBUG)
#logger = logging.getLogger("netmiko")

if len(sys.argv) == 1:
    HOST = input("Enter hostname: ")
elif len(sys.argv) == 2:
    HOST = sys.argv[1]

if (ip_functions.lookup(HOST) != 0):
    print("Host not found!")
    sys.exit(1)

if (ip_functions.ping(HOST) != 0):
    print("Host not reachable via ICMP!")
    sys.exit(1)

try:
    fc = open("comandos.txt", "r")
except:
    print("File comandos.txt not found!")
    sys.exit(1)

USER = input("Enter username: "******"Enter password: ")

my_device = {
    'host': HOST,
    'username': USER,