Quantcast
Channel: All Ethernet Switching posts
Viewing all articles
Browse latest Browse all 10307

Re: Script in EX 2200

$
0
0

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


Viewing all articles
Browse latest Browse all 10307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>