Hi,
Equivalent python script:
import warnings warnings.filterwarnings("ignore") from jnpr import junos device={'node1', 'node2'} for dev_host in device: dev=junos.Device(host=dev_host, user='username', password='pass', gather_facts=False) dev.open( ) out=dev.cli("show configuration protocols rsvp", warning=False) if out: print "%s: Config is present" %(dev_host) dev.close( )
Python script requires the Junos automation python library to be installed and netconf to be enabled on the devices.
The bash script with "if not empty" condition:
#!/bin/bash for node in $(cat /tmp/node.txt) do command=$(sshpass -p "password" ssh $node -o PubKeyAuthentication=no "show configuration protocols rsvp") if [ -n "$command" ] then echo "$node config present" else echo "$node config not present" fi done
Example:
#python show_config.py node1: Config is present # ./show-command.sh node1 config not present node2 config present
Please adapt the show commands & credentials accordingly.
Hope this helps.
Cheers,
Ashvin