Hi all,
I have script on linux server which is executing backup on mk routers and downloading thems:
(Script is done because I found lot of very useful informations here, in this forum, thx for help.)
LOGIN=admin
PASSWORD=password
SSHPORT=222
FTPPORT=211
IPLISTFILE=ips.list
SUBDIR=mkbackup
LOGFILE=mkbackup.log
index=0
while read line ; do
IPLIST[$index]="$line"
index=$(($index+1))
done < $IPLISTFILE
echo ${iplist[@]}
for (( i=0; i<${#IPLIST[@]}; i++ ));
do
HOSTIP=${IPLIST[$i]}
echo >>$LOGFILE
echo $HOSTIP `date +%Y%m%d%H%M%S` >>$LOGFILE
sshpass -p $PASSWORD ssh $LOGIN@$HOSTIP -p $SSHPORT -o StrictHostKeyChecking=no ':global zalohafile ( [/ system identity get name] . "-" . [:pick [/ sys clock get date] 7 11] . [:pick [/ sys clock get date] 0 3] . [:pick [/ sys clock get date] 4 6] . "-" . [:pick [/ sys clock get time] 0 2] . [:pick [/ sys clock get time] 3 5] . [:pick [/ sys clock get time] 6 8]) ; / system backup save name=$zalohafile ; / export file=$zalohafile' >>$LOGFILE 2>>$LOGFILE
wget -N -nv -P $SUBDIR/$HOSTIP ftp://$HOSTIP:$FTPPORT/* --ftp-user=$LOGIN --ftp-password=$PASSWORD >>$LOGFILE 2>>$LOGFILE
done
Script read list of ip address from file.
I put addresses to file manualy, but now I want make it by some script. I need to export ip addresses of items with “Platform=MikroTik” from [/ip neighbors] to some file.
# I can print only mikrotik devices:
:put [/ ip neighbour print where platform="MikroTik"]
# But with print I cannot store them into variable/array.
# I try to do it with "get" but without succes.
# Somehow extract item numbers of devices with platform=mikrotik
# / ip neighbor print where platform="MikroTik" get address ---> something like this but working and storing numbers to array
# Add each one to array:
:set bbb (:put $bbb , $nmbr) ; :put $bbb
# And then extract ip address using item numbers
:put [/ip neighbor get number=$i address]
Pls could someone help me? Thanks