User Tools

Site Tools


средства_программирования_shell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
средства_программирования_shell [2023/01/22 19:07]
val [Использование диалоговых окон]
средства_программирования_shell [2024/04/11 12:41] (current)
val [Web сервер на shell]
Line 79: Line 79:
  
 ==== Целочисленный цикл (поиск хостов в подсети) ==== ==== Целочисленный цикл (поиск хостов в подсети) ====
 +
 +  * [[Утилита nmap#Ping диапазона адресов с verbose и debug]]
 +
 <​code>​ <​code>​
 $ cat test_ping.sh $ cat test_ping.sh
Line 84: Line 87:
 #!/bin/sh #!/bin/sh
  
-test -z $1 && exit 1+#test -z $1 && exit 1 
 +#[ "​$1"​ ] || { echo Example: ./​test_ping.sh 10.5.11; exit 1; }
  
 i=1 i=1
Line 90: Line 94:
 do do
   test $i = 50 && continue   test $i = 50 && continue
-  ping -c 1 -W 1 $1.$i > /dev/null 2>&1 && echo $1.$i+  ping -c 1 -W 1 $1.$i > /dev/null 2>&1 && echo $1.$i || echo No $i
   i=$(($i + 1))   i=$(($i + 1))
 done done
Line 392: Line 396:
  
 read request read request
-##echo "​$request"​ >> $log       # ​not work with keepalived+##echo "​$request"​ >> $log       # ​for educational demonstration
  
 filename="​${request#​GET }" filename="​${request#​GET }"
Line 404: Line 408:
 do do
   read -r header   read -r header
-##  echo "​$header"​ >> $log       # ​not work with keepalived+##  echo "​$header"​ >> $log       # ​for educational demonstration
   [ "​$header"​ == $'​\r'​ ] && break;   [ "​$header"​ == $'​\r'​ ] && break;
 +##  [ "​$header"​ == $''​ ] && break; ​   # for STDIN/​STDOUT educational demonstration
 done done
  
Line 412: Line 417:
 #  echo `date` OK $filename on `hostname` >> $log #  echo `date` OK $filename on `hostname` >> $log
   echo -e "​HTTP/​1.1 200 OK\r"   echo -e "​HTTP/​1.1 200 OK\r"
-  echo -e "​Content-Type:​ $(/​usr/​bin/​file -bi \"$filename\")\r"+  echo -e "​Content-Type:​ $(/​usr/​bin/​file -bi $filename)\r"​
   echo -e "​\r"​   echo -e "​\r"​
   /bin/cat "​$filename"​   /bin/cat "​$filename"​
 else else
-#  echo "​$(date)"​ ERR $filename on "​$(hostname)"​ >> $log+#  echo "​$(date)"​ ERR $filename on "​$(hostname)"​ >> ​"$log"
   echo -e "​HTTP/​1.1 404 Not Found\r"​   echo -e "​HTTP/​1.1 404 Not Found\r"​
   echo -e "​Content-Type:​ text/​html;​\r"​   echo -e "​Content-Type:​ text/​html;​\r"​
Line 488: Line 493:
         PROG_THBIRD:​ "Mail client Thunderbird"​ "​$(on_off PROG_THBIRD "​$GP_OP_FILE"​)"​ \         PROG_THBIRD:​ "Mail client Thunderbird"​ "​$(on_off PROG_THBIRD "​$GP_OP_FILE"​)"​ \
         ROLE_ZAB_AG:​ "​Zabbix Agent" "​$(on_off ROLE_ZAB_AG "​$GP_OP_FILE"​)"​ \         ROLE_ZAB_AG:​ "​Zabbix Agent" "​$(on_off ROLE_ZAB_AG "​$GP_OP_FILE"​)"​ \
-        ​ROLE_OVPN_CL: "​OpenVPN Client"​ "​$(on_off ​ROLE_OVPN_CL ​"​$GP_OP_FILE"​)"​ \+        ​ROLE_OVPN1_CL: "​OpenVPN Client"​ "​$(on_off ​ROLE_OVPN1_CL ​"​$GP_OP_FILE"​)"​ \
 2>"​$TEMP_FILE"​ 2>"​$TEMP_FILE"​
  
средства_программирования_shell.1674403678.txt.gz · Last modified: 2023/01/22 19:07 by val