免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
1234下一页
最近访问板块 发新帖
查看: 13131 | 回复: 34
打印 上一主题 下一主题

[文本处理] syntax error: unexpected end of file [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-08-28 09:45 |只看该作者 |倒序浏览
本帖最后由 116264755 于 2013-08-28 09:52 编辑

在程序最后一行发生错误!!!
实际代码就后面几行。。。
运行时总是报错  就在exit那儿。。。exit在167行。。求助啊
./run: line 167: syntax error: unexpected end of file   
查看过格式:
vi run
:set ff?
是unix格式的。


#! /bin/bash

#*****************************************
#
# csh script used to run fakesat_menu
#
# D. W. Murphy        Last changed: 25-May-1995
#
#*****************************************

#
# In order for fakesat to run correctly a
# few environmental variables need to be set.
# If you need to set an environmental variable
# un-comment out the appropriate # setenv line
# by removing the # and then set the variable
# as you wish.


#*****************************************
# PGPLOT_FONT
#*****************************************

# set PGPLOT_FONT to the pathname of grfont.dat,
# if required.

export PGPLOT_FONT=/usr/lib/pgplot/grfont.dat

# notes:

# For pre 5.0 versions of PGPLOT there is no
# to set  PGPLOT_FONT if grfont.dat is in
# /usr/local/vlb/pgplot on SUN workstations

# For pre 5.0 versions of PGPLOT there is no
# to set  PGPLOT_FONT if grfont.dat is in
# /usr/src/pgplot on HP workstations


#*****************************************
# PGPLOT_DIR
#*****************************************

# In 5.0 or higher versions of PGPLOT:

# The environmental variable PGPLOT_DIR is used to show the
# location of:
# (i) the pgxwin_server program, if this program is not
# in a directory in your path.
# and
# (ii) the PGPLOT library, if it is not in the library path
# specified by the environmental variable LD_LIBRARY_PATH.

# set PGPLOT_DIR, if required:

# export PGPLOT_DIR=<directory name>

#*****************************************
# PGPLOT_XW_CLICKLEFT
#*****************************************

# In pre 5.0 versions of PGPLOT:

# If PGPLOT_XW_CLICKLEFT is set to 1.
# X windows created by fakesat will
# not be destroyed until there is a
# click of the left hand mouse button
# in them:

# set PGPLOT_XW_CLICKLEFT here, if required:

export PGPLOT_XW_CLICKLEFT=1

#*****************************************
# PGPLOT_XW_WIDTH
#*****************************************

# In pre 5.0 versions of PGPLOT:

# PGPLOT_XW_WIDTH set the size of an X window
# created by fakesat and fakesat_menu relative
# to a default size:

# set PGPLOT_XW_WIDTH here, if required:

export PGPLOT_XW_WIDTH=0.8

#*****************************************
# End of Environmental Variables
#*****************************************



#*****************************************
# Running fakesat_menu via an XWindow
#*****************************************

#  set menu_defaults = $1

# note: since -f is a csh file inquiry operator need
# to turn off this feature by creating the variable a

  set a=a$1

#  echo 'a is: ' $a

if($a == "a-h") then
echo  ' '
echo 'possible run options are:'
echo ' '
echo 'run    : run fakesat_menu with simple menu'
echo 'run -h : help option'
echo 'run -s : run fakesat_menu with simple menu'
echo 'run -c : run fakesat_menu with complex menu'
echo 'run -f : re-initialize everything by running fakesat_init -f'
echo '         followed by run'
echo '  '
exit
endif

  set menu = s
  set menu_defaults = menu_defaults

if( ${#argv} == 1 ) then
  set menu_defaults = $1
endif

if($a == "a-f") then
echo 'run -f option: '
fakesat_init -f
set menu = s
set menu_defaults = menu_defaults
endif

if($a == "a-s") then
echo 'run -s option: using simple menu'
set menu = s
set menu_defaults = menu_defaults
endif

if($a == "a-c") then
echo 'run -c option: using complex menu'
set menu = c
set menu_defaults = menu_defaults
endif

if( ${#argv} == 2 ) then
  set menu_defaults = $2
endif

if(! -e $menu_defaults ) then
echo ' '
echo '***************************************************'
echo ' ERROR in starting up fakesat_menu'
echo ' menu_defaults file: ' $menu_defaults ' does NOT exist'
echo '***************************************************'
echo ' '
exit
endif

fakesat_menu << EOD
$menu_defaults
$menu
EOD

exit

论坛徽章:
60
20周年集字徽章-20	
日期:2020-10-28 14:04:3015-16赛季CBA联赛之北京
日期:2016-07-06 15:42:0715-16赛季CBA联赛之同曦
日期:2016-06-12 10:38:0915-16赛季CBA联赛之佛山
日期:2016-05-27 11:54:56黄金圣斗士
日期:2015-12-02 11:44:35白银圣斗士
日期:2015-11-25 14:32:43白银圣斗士
日期:2015-11-23 12:53:352015亚冠之布里斯班狮吼
日期:2015-10-21 16:55:482015亚冠之首尔
日期:2015-09-01 16:46:052015亚冠之德黑兰石油
日期:2015-08-31 11:39:192015亚冠之萨济拖拉机
日期:2015-08-28 21:06:5315-16赛季CBA联赛之广东
日期:2016-07-12 14:58:53
2 [报告]
发表于 2013-08-28 09:53 |只看该作者
感觉很怪,怪怪的,怪怪怪怪的

if后面能有个空格么?endif 又是神马玩意儿?

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
3 [报告]
发表于 2013-08-28 09:57 |只看该作者
本帖最后由 waker 于 2013-08-28 09:57 编辑

#! /bin/bash

#*****************************************
#
# csh script used to run fakesat_menu

用英制的螺母套公制的螺栓?

论坛徽章:
0
4 [报告]
发表于 2013-08-28 10:02 |只看该作者
回复 2# reyleon


    本来是csh的,我改为了bash。endif现在用fi代替了。但是还是报错。

kenlf0508@ubuntu:~/Downloads/fakerat$ ./run
./run: line 107: ==: command not found
./run: line 124: 0: command not found
./run: line 128: ==: command not found
./run: line 135: ==: command not found
./run: line 141: ==: command not found
./run: line 147: 0: command not found
./run: line 151: -e: command not found

***************************************************
ERROR in starting up fakesat_menu
menu_defaults file:   does NOT exist
***************************************************

论坛徽章:
0
5 [报告]
发表于 2013-08-28 10:04 |只看该作者
回复 3# waker


    起初是#! /bin/csh的。。。我是unbuntu。。bin里只有bash。。然后我改为了bash试试。。然后把代码也改了改。。setenv改为export 。。现在endif改为了fi

论坛徽章:
39
辰龙
日期:2013-08-21 15:45:192015亚冠之广州富力
日期:2015-05-12 16:34:52亥猪
日期:2015-03-03 17:22:00申猴
日期:2015-03-03 17:21:37未羊
日期:2014-10-10 13:45:41戌狗
日期:2014-06-17 09:53:29巨蟹座
日期:2014-06-12 23:17:17双鱼座
日期:2014-06-10 12:42:44寅虎
日期:2014-06-09 12:52:172015亚冠之卡尔希纳萨夫
日期:2015-05-24 15:24:35黄金圣斗士
日期:2015-12-02 17:25:0815-16赛季CBA联赛之吉林
日期:2017-06-24 16:43:52
6 [报告]
发表于 2013-08-28 10:09 |只看该作者
本帖最后由 关阴月飞 于 2013-08-28 10:41 编辑

回复 5# 116264755

把所有 if 后面的 ()改成 [[ ]] 再说:
    if($a == "a-h") then   ==》  if [[ $a == "a-h" ]];then

论坛徽章:
0
7 [报告]
发表于 2013-08-28 10:15 |只看该作者
回复 6# 关阴月飞


    好的!!!我马上试试!!谢谢大神!!!

论坛徽章:
0
8 [报告]
发表于 2013-08-28 10:30 |只看该作者
回复 6# 关阴月飞


    全改了变成这样。。。

kenlf0508@ubuntu:~/Downloads/fakerat$ ./run
./run: line 107: syntax error near unexpected token `then'
./run: line 107: `if[[$a == "a-h"]]; then'

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
9 [报告]
发表于 2013-08-28 10:40 |只看该作者
本帖最后由 Shell_HAT 于 2013-08-28 10:40 编辑

回复 8# 116264755
  1. if [[ $a == "a-h" ]]
复制代码
空格不能少

论坛徽章:
39
辰龙
日期:2013-08-21 15:45:192015亚冠之广州富力
日期:2015-05-12 16:34:52亥猪
日期:2015-03-03 17:22:00申猴
日期:2015-03-03 17:21:37未羊
日期:2014-10-10 13:45:41戌狗
日期:2014-06-17 09:53:29巨蟹座
日期:2014-06-12 23:17:17双鱼座
日期:2014-06-10 12:42:44寅虎
日期:2014-06-09 12:52:172015亚冠之卡尔希纳萨夫
日期:2015-05-24 15:24:35黄金圣斗士
日期:2015-12-02 17:25:0815-16赛季CBA联赛之吉林
日期:2017-06-24 16:43:52
10 [报告]
发表于 2013-08-28 10:40 |只看该作者
回复 8# 116264755
注意空格呀!!!!
  1. if[[$a == "a-h"]];then    ==> if [[ $a == "a-h" ]];then
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP