Bash的错误:“b。第52行:语法错误:文件注销意外结束

时间:2023-02-10 22:46:28

So, I wanted this to download a file from my computer, transfer it to my iPhone, install the file there, and respring my phone. For some reason the error you saw in the title pops up. Would be nice if someone could help, thanks.

所以,我想要从我的电脑上下载一个文件,把它转到我的iPhone上,在那里安装文件,然后再将我的手机重新命名。由于某种原因,你在标题中看到的错误出现了。如果有人能帮忙就好了,谢谢。

#!/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

1 个解决方案

#1


1  

These lines:

这些线:

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

have the problem. The EOF is not at the beginning of the line (indented by one space), so it is not the end of the here-doc, and hence the here-doc is not terminated until the end of the file (where there happens to be a second EOF that's supposed to be terminating a second here-doc), and that generates the error message because the if is not terminated with a fi. Unindent EOF and you should be in business.

有问题。EOF不是一开始的行(缩进一个空间),所以它不是here-doc结束,因此here-doc才终止文件的末尾(恰好是第二个EOF应该是终止第二here-doc),生成的错误消息,因为如果不是fi终止。你应该从事商业活动。

#1


1  

These lines:

这些线:

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

have the problem. The EOF is not at the beginning of the line (indented by one space), so it is not the end of the here-doc, and hence the here-doc is not terminated until the end of the file (where there happens to be a second EOF that's supposed to be terminating a second here-doc), and that generates the error message because the if is not terminated with a fi. Unindent EOF and you should be in business.

有问题。EOF不是一开始的行(缩进一个空间),所以它不是here-doc结束,因此here-doc才终止文件的末尾(恰好是第二个EOF应该是终止第二here-doc),生成的错误消息,因为如果不是fi终止。你应该从事商业活动。