bash multithreading xargs / reboot grandstream voip phones.

Метки: shell script

example reboot phone usage phone-reboot 192.168.0.1

#!/bin/bash

sid=$(curl -s -c /tmp/cookies.txt -d"password=admin" http://${1}/cgi-bin/dologin | sed -r 's|.*"sid" : "([0-9a-z]+)".*|\1|' )
curl -b /tmp/cookies.txt -d"request=REBOOT&sid=${sid}" http://${1}/cgi-bin/api-sys_operation

reboot all founded:

#!/bin/bash +x
str1=`arp -an | grep 00:0B`
rm -rf /tmp/tmp0011
while IFS= read -r line
do
ip=$(echo -n $line | grep -o -E '([0-9]{1,3}\.){3}[0-9a-z]{1,3}')
if [ "${ip}" ] ; then
        echo Rebooting ${ip}
        echo ${ip} >> /tmp/tmp0011
        fi
done <<< "$str1"

xargs -P 0 -n 1 ./phone-reboot </tmp/tmp0011

Tags for bash multithreading xargs / reboot grandstream voip phones.
Вход в систему
Image CAPTCHA
Enter the characters shown in the image.