This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
средства_программирования_shell [2025/05/13 11:41] val [Средства программирования shell] |
средства_программирования_shell [2025/08/18 16:51] (current) val [Ресурсы Web сервера на shell] |
||
---|---|---|---|
Line 396: | Line 396: | ||
#!/bin/bash | #!/bin/bash | ||
base=/var/www | base=/var/www | ||
- | #log=/var/log/webd.log | + | #exec 2>>/var/log/webd.log |
+ | #echo "ARGS: $*" >&2 | ||
read request | read request | ||
- | ##echo "$request" >> $log # for educational demonstration | + | ##echo "$request" >&2 # for educational demonstration |
filename="${request#GET }" | filename="${request#GET }" | ||
Line 411: | Line 412: | ||
do | do | ||
read -r header | read -r header | ||
- | ## echo "$header" >> $log # for educational demonstration | + | ## echo "$header" >&2 # for educational demonstration |
[ "$header" == $'\r' ] && break; | [ "$header" == $'\r' ] && break; | ||
## [ "$header" == $'' ] && break; # for STDIN/STDOUT educational demonstration | ## [ "$header" == $'' ] && break; # for STDIN/STDOUT educational demonstration | ||
Line 418: | Line 419: | ||
if [ -e "$filename" ] | if [ -e "$filename" ] | ||
then | then | ||
- | # echo `date` OK $filename on `hostname` >> $log | + | # echo `date` OK $filename on `hostname` >&2 |
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" | ||
Line 424: | Line 425: | ||
/bin/cat "$filename" | /bin/cat "$filename" | ||
else | else | ||
- | # echo "$(date)" ERR "$filename" on "$(hostname)" >> "$log" | + | # echo "$(date)" ERR "$filename" on "$(hostname)" >&2 |
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 453: | Line 454: | ||
<code> | <code> | ||
- | # wget -O /var/www/img/logo.gif http://val.bmstu.ru/unix/Media/logo.gif | + | # wget -O /var/www/img/logo.gif https://val.bmstu.ru/unix/Media/logo.gif |
</code> | </code> | ||
* [[Сервис INETD]] | * [[Сервис INETD]] | ||
+ | * [[Управление сервисами в Linux#Systemd Sockets]] | ||
==== Проверка ==== | ==== Проверка ==== | ||
Line 469: | Line 471: | ||
==== Отправка email с вложениями ==== | ==== Отправка email с вложениями ==== | ||
+ | * [[Утилита curl]] | ||
* [[https://serverfault.com/questions/38919/send-an-email-with-an-attached-file-using-telnet-or-netcat|Send an email with an attached file using telnet or netcat]] | * [[https://serverfault.com/questions/38919/send-an-email-with-an-attached-file-using-telnet-or-netcat|Send an email with an attached file using telnet or netcat]] | ||