Who rated this post

cancel
Showing results for 
Search instead for 
Did you mean: 
oconnork
Contributor

You are right, I modified my post to details how to execute the script. 

But you may also use this script to have a good start to run commands on multiples gateways. 

For the ones that would want to run whatever commands on multiples remote gateways, you can use almost the same script.

See the below script, just modify the variable input and put the command you want to run on your gateways.
the outputs will be something like this : 


==================================
26-Sep-2022_16h-06m-21s
==================================
10.X.X.X;gateway1 ;This is Check Point's software version R81.10 - Build 020
10.X.X.X;gateway2 ;This is Check Point's software version R81.10 - Build 020

...

 

#!/bin/bash

LOGFILE=mylog.txt
touch $LOGFILE

echo "==================================" >> $LOGFILE
echo "$(/bin/date +%d-%b-%Y_%Hh-%Mm-%Ss)" >> $LOGFILE
echo "==================================" >> $LOGFILE


if [ $# -eq 1 ]
then
GATEWAYS="$1"
else
echo " Please, add the text file as an arguments"
exit 1
fi


which cprid_util 1> /dev/null 2> /dev/null
if [ "$?" -ne 0 ];
then
echo -e "\nCould not find the 'cprid_util' executable. Exiting..." | tee -a $LOGFILE
exit 1
fi

if [ ! -f gatewaysIP.txt ];
then
echo "Could not find the list of managed Security Gateways -" | tee -a $LOGFILE
echo "the 'gatewaysIP.txt' file in the current directory $(pwd)" | tee -a $LOGFILE
exit 2
fi

# Change here the fw ver by the command you want to run on the gateways
input="fw ver"

while read GATEWAY
do
echo -n "$GATEWAY;" | tee -a $LOGFILE
echo $(cprid_util -server $GATEWAY -verbose rexec -rcmd /bin/bash -c "hostname && echo -n ';' && $input") | tee -a $LOGFILE
done < $GATEWAYS

 

0 Kudos
(1)
Who rated this post