Code: Select all
import os
from dotenv import load_dotenv
from pathlib import Path
dotenv_path = Path(r'C:\Users\user\Desktop\PythonScripts\.env')
load_dotenv(dotenv_path=dotenv_path)
username = os.getenv('env_username')
password = os.getenv('env_password')
def main():
# Open list with IP addresses
with open(r"C:\Users\user\Desktop\PythonScripts\ipaddresses", "r") as f:
for host in f:
modified_host = modify(host)
connection_string = f"/SSH2 /L {username} /PASSWORD {password} {modified_host}"
print(f"Connection string: {connection_string}")
crt.Session.ConnectInTab(connection_string)
main()