다음 스크립트를 작성했습니다. 아직 색인을 지원하지 않습니다. 내가 겪고있는 문제는 netcat을 사용하여 페이지를로드하는 것과 관련이있다. 명령 줄을 사용하여 수동으로이 작업을 수행 할 수 있지만 스크립트에서 오류없이 수행 할 수있는 명령과 똑같은 명령을 실행하려고 할 때 수행 할 수 있습니다. 내가 생각할 수있는 유일한 방법은 출력물이 다른 곳으로 이동한다는 것입니다.netcat을 사용하여 bash에서 http get 요청을 발행하십시오.
#!/bin/bash
PORT=80
while [ true ]
do
echo "Type the address you wish to visit then, followed by [ENTER]:"
read address
path=${address#*/}
domain=${address%%/*}
nc $domain $PORT
printf "GET /$path HTTP/1.1\n"
printf "Host: $domain\n"
printf "\n"
printf "\n"
done
'[true] '는 실제로 생각한대로 작동하지 않지만 실제로 작동합니다. 'while true '또는''nonempty-string-is-still-nonempty' '를 의미합니다. – tripleee
접두사 관련 : https://stackoverflow.com/questions/36371221/bash-if-statement-too-many-arguments ; 또한 https://stackoverflow.com/questions/37586811/pass-commands-as-input-to-another-command-su-ssh-sh-etc는 실제로 이것에 관한 것이 아니지만 잘하면 정신 모델을 명확히하는 데 도움이됩니다. 스크립트의 작동 방식. – tripleee