我一直在寻找答案,但找不到任何答案,所以这是我在“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。