Some commands towards different devices requirement prompt inputs. This is how you manage this situation :
Example of multiple prompt for a single command.
ping = net_connect.send_command(“ping”)
#by trying this script it is going to endup in a timeout error
OSError: Search pattern never detected in send_command_expect: since it is waiting for an input. It need more actions .
ipv4 = input(“please enter an ip:”)
ping = “ping”
output = net_connect.send_command_timing(“ping”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(ipv4, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
output += net_connect.send_command_timing(“\n”, strip_prompt=False, strip_command=False)
print(output)
Another example :
Next step is to create a condition to shrink that code : using ‘:’ as the expected string. but its not working yet will need to go back on it and this is what i wrote so far :
*********************************************************************
output = net_connect.send_command(“ping”, strip_prompt=False, strip_command=False)
if “Target IP address” in output:
output += net_connect.send_command_timing(ipv4, strip_prompt=False, strip_command=False)
else:
output += net_connect.send_command(‘\n’, strip_prompt=False, strip_command=False)
print(output)
*********************************************************************