![BASH: 예상치 못한 '완료' 표시 근처에서 구문 오류가 발생했습니다.](https://linux55.com/image/115617/BASH%3A%20%EC%98%88%EC%83%81%EC%B9%98%20%EB%AA%BB%ED%95%9C%20'%EC%99%84%EB%A3%8C'%20%ED%91%9C%EC%8B%9C%20%EA%B7%BC%EC%B2%98%EC%97%90%EC%84%9C%20%EA%B5%AC%EB%AC%B8%20%EC%98%A4%EB%A5%98%EA%B0%80%20%EB%B0%9C%EC%83%9D%ED%96%88%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
답변을 찾고 있었지만 찾을 수 없었으므로 여기 "od -a"에 내 코드가 있습니다.
LiamBogur@LIAMBOGUR:/mnt/c/Users/traci/Desktop$ od -a ethedit2.sh
0000000 # ! / b i n / b a s h nl e t h v
0000020 i e w s t a t u s = 0 nl e t h v
0000040 i e w m o d e = 0 nl e t h v i e
0000060 w p r o t o c o l = 0 nl w h i l
0000100 e sp [ sp $ e t h e d i t s t a t
0000120 u s sp = sp 1 sp ] nl d o nl i f sp [
0000140 sp $ e t h e d i t m o d e sp = sp
0000160 0 sp ] nl t h e n nl i f sp [ sp $ e
0000200 t h e d i t p r o t o c o l sp =
0000220 sp 0 sp ] nl t h e n nl n c sp - l sp
0000240 - v sp 2 2 2 3 sp | sp n c sp l o c
0000260 a l h o s t sp 2 2 2 2 nl f i nl i
0000300 f sp [ sp $ e t h e d i t p r o t
0000320 o c o l sp = sp 1 sp ] nl t h e n nl
0000340 n c sp - l sp - v sp - u sp 2 2 2 3
0000360 sp | sp n c sp l o c a l h o s t sp
0000400 2 2 2 2 nl f i nl f i nl i f sp [ sp
0000420 $ e t h e d i t m o d e sp = sp 1
0000440 sp ] nl t h e n nl i f sp [ sp $ e t
0000460 h e d i t p r o t o c o l sp = sp
0000500 0 sp ] nl t h e n nl n c sp - l sp -
0000520 v sp - w 1 5 sp 2 2 2 1 sp | sp e t
0000540 h e d i t i p = nl n c sp - l sp -
0000560 v sp 2 2 2 2 sp | sp n c sp $ e t h
0000600 e d i t i p sp 2 2 2 3 nl f i nl i
0000620 f sp [ sp $ e t h e d i t p r o t
0000640 o c o l sp = sp 1 sp ] nl t h e n nl
0000660 n c sp - l sp - v sp - w 1 5 sp 2 2
0000700 2 1 sp | sp e t h e d i t i p = nl
0000720 n c sp - l sp - v sp 2 2 2 2 sp | sp
0000740 n c sp - u sp $ e t h e d i t i p
0000760 sp 2 2 2 3 nl f i nl d o n e nl e c
0001000 h o sp d o n e nl
0001010
다음으로 찾을 수 있는 것은 nil 문자이므로 수정하는 방법을 모르겠습니다. 도와주세요.
편집 : 이것은 원래 코드입니다
#!/bin/bash
ethviewstatus=0
ethviewmode=0
ethviewprotocol=0
while [ $etheditstatus = 1 ]
do
if [ $etheditmode = 0 ]
then
if [ $etheditprotocol = 0 ]
then
nc -l -v 2223 | nc localhost 2222
fi
if [ $etheditprotocol = 1 ]
then
nc -l -v -u 2223 | nc localhost 2222
fi
fi
if [ $etheditmode = 1 ]
then
if [ $etheditprotocol = 0 ]
then
nc -l -v -w15 2221 | etheditip=
nc -l -v 2222 | nc $etheditip 2223
fi
if [ $etheditprotocol = 1 ]
then
nc -l -v -w15 2221 | etheditip=
nc -l -v 2222 | nc -u $etheditip 2223
fi
done
echo done
답변1
if
다음을 사용하여 "끄지" 마십시오 fi
.
if [ $etheditmode = 1 ]
여러분(그리고 다른 사람들)이 더 쉽게 읽을 수 있도록 코드를 들여쓰기하고 shellcheck.net을 확인해 보세요.