Witam,
Potrzebuję włożyc do pinga dynamiczna nazwe zmiennej, Zmienna już utworzyłem, działa i wyświetla to co zaplanowałem.
Jednak potrzebuje wrzucic ją do komendy ping i tutaj zaczynaja się schody
declare -A array=([piotr_pc]=10.0.0.10 [piotr_samsung]=10.0.0.11 [piotr_work]=10.0.0.12 [magda_laptop]=10.0.0.13)
for item in ${!array[*]}
do
file=$(grep $item homesystem/web/openvpn-status.log | tr 'm\n' 'p,')
IFS=','
for x in $file
do
eval $item+=\("$x"\)
done
eval echo \${$item[9]}
if ping -c1 -w1 eval echo \${$item[9]} > /dev/null; then
Wynik:
root@VigoradoNetwork:/www1# ./ping.sh
BusyBox v1.28.3 () multi-call binary.
Usage: ping [OPTIONS] HOST
Send ICMP ECHO_REQUEST packets to network hosts
-4,-6 Force IP or IPv6 name resolution
-c CNT Send only CNT pings
-s SIZE Send SIZE data bytes in packets (default 56)
-t TTL Set TTL
-I IFACE/IP Source interface or IP address
-W SEC Seconds to wait for the first response (default 10)
(after all -c CNT packets are sent)
-w SEC Seconds until ping exits (default:infinite)
(can exit earlier with -c CNT)
-q Quiet, only display output at start
and when finished
-p HEXBYTE Pattern to use for payload
OFFLINE