语法错误:意外的文件结尾(期望"then") [英] Syntax error: end of file unexpected (expecting "then")

查看:458
本文介绍了语法错误:意外的文件结尾(期望"then")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的世界服务器插件更新程序编写此代码 我是一个新的Shell脚本编写者,所以我不知道...
当我运行此代码时,我得到一个错误:

I am making this code for a minecraft server plugin updater I am a new shell scripter so I don't know alot...
when I run this code I get a error:

#!/bin/sh
export PATH=$PATH:.
#Options
PLUGINDOWNLOADLINK=http://api.bukget.org/3/plugins/bukkit/$PLUGINNAME/latest/download
# Plugin folder
if [ -f $PWD\plugins ]; then
PLUG=$PWD\plugins 
else
PLUG=$PWD\plug-ins
fi

cd $PLUG

if [ ! -f .\update ]; then
mkdir update
echo Making Directory "update"..
fi

# Plugins Found
    for i in $( ls );
    do
        PLUGINNAME=$i
    done
    cd .\update

    wget $PLUGINDOWNLOADLINK

    # No Plugins Found
    if [ ! -f $PLUG ]; then
    echo
echo
echo    No plugin found.
echo
echo
echo
echo   Plugins can be downloaded here:
echo   http://dev.bukkit.org/bukkit-plugins
fi

# stop 
sleep 3s
exit

我收到此错误:

Syntax error: end of file unexpected (expecting "then")

所以我将"then"放在想要我的位置,然后再次运行:
它现在给了我这个错误:

so I put "then" in the place it wanted me to and ran it again:
it gave me this error now:

Syntax error: end of file unexpected

我在Windows 7记事本++上写的
我该如何解决?

I wrote it on windows 7 notepad++
how can I fix this?

推荐答案

我遇到了同样的问题.问题是文件的格式是"dos",但是在linux shell中需要"unix",所以我安装了"dos2unix"

I have met the same problem. And the problem is the format of the file is "dos", but in linux shell requires "unix", so I install the "dos2unix"

$ sudo apt-get install dos2unix

或者如果您使用emacs,则可以执行以下操作:

or if you use emacs, you can do this:

C-x RET f unix

祝你好运 :)

这篇关于语法错误:意外的文件结尾(期望"then")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆