
나는 내가 읽은 많은 조각과 튜토리얼을 기반으로 쉘 스크립트를 만들었습니다. 구문 오류를 수정하고 작동시키는 방법을 알 수 없습니다. 터미널 출력은 다음과 같습니다:
./afkscript.sh: 2 ./afkscript.sh: Syntax error: "(" unexpected ( expecting "done")
튜토리얼에서 읽은 내용에 따르면 해당 괄호가 필요합니다. 내 스크립트는 다음과 같습니다(창 이름이 교체됨).
while true
do
sleep $[ ( $RANDOM % 10 ) + 1 ]s
DIFF=$((46-1+1))
R=$ ( ( $ ( ($RANDOM%DIFF) ) +1) )
if [[ "R" -eq 1 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "a"
elif [[ "R" -eq 2 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type ""
elif [[ "R" -eq 3 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "d"
elif [[ "R" -eq 4 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "f"
elif [[ "R" -eq 5 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "g"
elif [[ "R" -eq 6 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "h"
elif [[ "R" -eq 7 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "j"
elif [[ "R" -eq 8 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "k"
elif [[ "R" -eq 9 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "l"
elif [[ "R" -eq 10 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type ";"
elif [[ "R" -eq 11 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "'"
elif [[ "R" -eq 12 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "\"
elif [[ "R" -eq 13 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "q"
elif [[ "R" -eq 14 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "w"
elif [[ "R" -eq 15 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "e"
elif [[ "R" -eq 16 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "r"
elif [[ "R" -eq 17 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "t"
elif [[ "R" -eq 18 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "y"
elif [[ "R" -eq 19 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "u"
elif [[ "R" -eq 20 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "i"
elif [[ "R" -eq 21 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "o"
elif [[ "R" -eq 22 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "p"
elif [[ "R" -eq 23 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "["
elif [[ "R" -eq 24 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "]"
elif [[ "R" -eq 25 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "1"
elif [[ "R" -eq 26 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "2"
elif [[ "R" -eq 27 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "3"
elif [[ "R" -eq 28 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "4"
elif [[ "R" -eq 29 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "5"
elif [[ "R" -eq 30 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "6"
elif [[ "R" -eq 31 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "7"
elif [[ "R" -eq 32 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "8"
elif [[ "R" -eq 33 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "9"
elif [[ "R" -eq 34 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "0"
elif [[ "R" -eq 35 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "-"
elif [[ "R" -eq 36 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "="
elif [[ "R" -eq 37 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "z"
elif [[ "R" -eq 38 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "x"
elif [[ "R" -eq 39 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "c"
elif [[ "R" -eq 40 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "v"
elif [[ "R" -eq 41 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "b"
elif [[ "R" -eq 42 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "n"
elif [[ "R" -eq 43 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "m"
elif [[ "R" -eq 44 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type ","
elif [[ "R" -eq 45 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "."
elif [[ "R" -eq 46 ]]; then
xdotool search --name "WINDOWNAME" windowactivate --sync
sleep .05
xdotool type "/"
else
break
fi
done
답변1
귀하의 제목에 따라 무한 진술은 그에 따라 논리가 조정된 if
것일 뿐입니다 .while
또한 코드가 매우 복잡하여 긴급하게 일부 형식을 사용해야 합니다.
그 외에도 당신은해야네 오류를 읽어봐. 어딘가에 추가 괄호가 있다는 것이 분명하게 명시되어 있으므로 코드를 자세히 살펴보고 해결책을 찾으려면 실험해 보세요. 실제로 답변을 제공하려면 괄호가 시작되기 전에 '$'를 움직여야 한다고 지금 말씀드리겠습니다. 이것이 바로 변수가 작동하는 방식입니다.
마지막으로, 제목이 향후 질문과 관련이 있는지 확인하세요.