Oct-19-2021, 04:13 PM
Good morning!
I'm scanning a list of hosts to see a host has a specific directory and if not "continue' to the next host.
I thought I would use try/except but it did not work if the host asked for a password the code just stops.
I'd like to 'skip' the host if it prompts for 'username/pass'
here is a try/except snippet:
Thank you.
I'm scanning a list of hosts to see a host has a specific directory and if not "continue' to the next host.
I thought I would use try/except but it did not work if the host asked for a password the code just stops.
I'd like to 'skip' the host if it prompts for 'username/pass'
here is a try/except snippet:
try : subprocess.call("net use U: /delete /yes") subprocess.call("net use U: "+"\\\\"+hnm_sp+"\\C$") print(f" Dir mounted ----- {hnm_sp}") except OSError as st : print(f" Mounting Error {hnm_sp}") continue try : if os.path.exists('\\\\"+hnm_sp+pth_to_file') : print(f" Host Directory found - > {host_path}") except OSError as st : print(f" Host does not have Directory -->{hnm_sp}") continue
Thank you.