9月末に発売されたシェル芸本の続きです。
前回はこちら
問題151
$ curl http://file.ueda.tech/eki/l/11302.xml > a $ cat a | grep -Pe "lon|lat|name" | sd '<[^>]+>' '' | awk '{print $1}' | xargs -n3 | while read D E F; do echo $D $(curl "https://cyberjapandata2.gsi.go.jp/general/dem/scripts/getelevation.php?lon=$E&lat=$F" | jq -r '.elevation'); sleep 1s; done
問題152
$ while true; do command wget localhost:8000/index.html |& grep 200 &> /dev/null && echo Success || echo Warning; sleep 1s; done Success Success Success ...
問題153
$ (echo -e "HEAD / HTTP/1.1\nHost: www.google.co.jp\n\n";sleep 1s) | telnet www.google.co.jp 80
問題154
$ echo wget curl ping dig nslookup | fmt -1 | while read CMD; do sudo strace -f $CMD google.com |& grep /etc/hosts && echo $CMD; done
問題155
$ echo -n test > index.html&&python3 -m http.server $ curl localhost:8000 -v * Trying 127.0.0.1:8000... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8000 (#0) > GET / HTTP/1.1 > Host: localhost:8000 > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse * HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Server: SimpleHTTP/0.6 Python/3.9.0 < Date: Tue, 21 Dec 2021 12:52:52 GMT < Content-type: text/html < Content-Length: 4 < Last-Modified: Tue, 21 Dec 2021 12:52:51 GMT < * Closing connection 0 test $ (echo -e "HTTP/1.1 200 OK\nContent-Length: 5";echo -en "\ntest") | nc -N -l 8080