Bash error: "b.sh: line 52: syntax error: unexpected end of file logout"

Bash error: "b.sh: line 52: syntax error: unexpected end of file logout"

所以,我想让它从我的计算机下载一个文件,将其传输到我的 iPhone,在那里安装文件,然后重新启动我的 phone。出于某种原因,您在标题中看到的错误会弹出。如果有人可以提供帮助,那就太好了,谢谢。

#!/bin/bash
clear
cd downloads
if [ ! -d ".tmpdl" ]; then
  mkdir ".tmpdl"
fi
cd .tmpdl
echo "Enter .deb link:"
read dllink
echo "Enter name of tweak (simple):"
read name
echo "Enter IP of device:"
read IP
echo "Enter your SSH password. If you don't know what this is enter 'alpine' without the apostrophes."
read pass
echo "Sending test file..."
touch test.txt
sshpass -p "$pass" scp test.txt root@"$IP":/var/mobile/Documents
echo "If the transfer was successful (no permission denied error) enter yes or no if it wasn't."
read reply1
if [ $reply1 == no ]; then
 echo "Error, wrong credentials, try again."
 exit
fi
echo "Okay, attempting to download file..."
curl -o "$name".deb "$dllink"
if [ ! -d "tmp" ]; then
  sshpass -p "$pass" ssh root@"$IP" << EOF
   cd /
   cd var/mobile/Documents
   mkdir tmp
 EOF
fi

sshpass -p "$pass" scp "$name".deb root@192.168.1.104:/var/mobile/Documents/tmp
echo "Sent file, deleting it from here..."
cd ..
rm -rf .tmpdl
sshpass -p "$pass" ssh root@"$IP" << EOF
  cd /
  cd var/mobile/Documents
  mkdir tmp
  mv "$name".deb tmp/
  cd tmp
  dpkg -i "$name".deb
  echo "Clearing caches..."
  cd ..
  rm -rf tmp
  echo "Done installing, respringing now..."
  killall backboardd
EOF

这些行:

if [ ! -d "tmp" ]; then
  sshpass -p "$pass" ssh root@"$IP" << EOF
   cd /
   cd var/mobile/Documents
   mkdir tmp
 EOF
fi

有问题。 EOF 不在行首(缩进一个 space),因此它不是 here-doc 的末尾,因此 here-doc 直到文件末尾才终止(其中碰巧有第二个 EOF 应该终止第二个 here-doc),并且会生成错误消息,因为 if 没有以 fi 终止。取消缩进 EOF,你应该开始做生意了。