求教,遇到bash: syntax error near unexpected token 的问题
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
求教,遇到bash: syntax error near unexpected token 的问题
我最近才刚刚开始接触linux,为了调通一个cmu大学的目标检测程序。
其中有一行代码是在matlab下运行:
[tmp,lenstring]=unix(/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration)
最后的返回值老是有问题,
我就把unix(/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration)直接在terminal中运行
发现报错:bash: syntax error near unexpected token `/usr/bin/ffmpeg'。查了一下之后,说是语法问题。。。请问,unix不认这个路径么?还是什么问题?
谢谢!
其中有一行代码是在matlab下运行:
[tmp,lenstring]=unix(/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration)
最后的返回值老是有问题,
我就把unix(/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration)直接在terminal中运行
发现报错:bash: syntax error near unexpected token `/usr/bin/ffmpeg'。查了一下之后,说是语法问题。。。请问,unix不认这个路径么?还是什么问题?
谢谢!
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
那个程序当中需要的,下载下来就是这样。。。如果不用unix,可以怎么改?这个代码是matlab中的,意思是unix下运行后面那句话eexpress 写了:带unix()干嘛
- 枫叶饭团
- 帖子: 14683
- 注册时间: 2010-06-16 1:05
- 系统: Mac OS X
- 来自: Tencent
- 联系:
Re: 求教,遇到bash: syntax error near unexpected token 的问题
把前面的unix(和最后的)删掉。
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
由于我是需要在matlab里运行这个命令:/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration。如果直接去掉的话,是没法执行的枫叶饭团 写了:把前面的unix(和最后的)删掉。
- wjchen
- 帖子: 583
- 注册时间: 2011-05-02 19:08
- 系统: ubuntu 12.04
Re: 求教,遇到bash: syntax error near unexpected token 的问题
matlab下运行shell命令:
1、感叹号+命令
2、unix(注意command要加单引号)
不过在我这里运行的结果:
在终端下是正常的。好像要想办法配置一下matlab的动态链接库。解决方法:
1、感叹号+命令
代码: 全选
!/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration
代码: 全选
Syntax:
unix command
status = unix('command')
[status, result] = unix('command')
[status,result] = unix('command','-echo')
代码: 全选
unix('ffmpeg')
ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directory
代码: 全选
sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
wjchen 写了:matlab下运行shell命令:
1、感叹号+命令2、unix(注意command要加单引号)代码: 全选
!/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration
不过在我这里运行的结果:代码: 全选
Syntax: unix command status = unix('command') [status, result] = unix('command') [status,result] = unix('command','-echo')
在终端下是正常的。好像要想办法配置一下matlab的动态链接库。解决方法:代码: 全选
unix('ffmpeg') ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directory
代码: 全选
sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8
您好,非常感谢您的回答~我这的目的是在matlab下可以运行这个代码,在我运行[tmp,lenstring] = unix('/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration')的时候,是可以的,但是返回值不对,lenstring是空的,tmp是1。而我在运行您在前面所说的前面加!的方法,运行不出错,但是没有返回值啊,什么反应都没有。。。
请问这个返回值不对是什么意思?
我在terminal下运行/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration的时候,是没问题的,能显示:Duration: 00:03:38.96, start: 0.000000, bitrate: 4005 kb/s。
是否是matlab调用出问题?
谢谢!
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
我在运行matlab中运行unix('ffmpeg')后也出现了ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directorywjchen 写了:matlab下运行shell命令:
1、感叹号+命令2、unix(注意command要加单引号)代码: 全选
!/usr/bin/ffmpeg -i "/home/ly/Documents/movie/AVSS_AB_Easy_Divx.avi" 2>&1 | grep Duration
不过在我这里运行的结果:代码: 全选
Syntax: unix command status = unix('command') [status, result] = unix('command') [status,result] = unix('command','-echo')
在终端下是正常的。好像要想办法配置一下matlab的动态链接库。解决方法:代码: 全选
unix('ffmpeg') ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directory
代码: 全选
sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8
但是在终端中sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8之后,仍然ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directory。我查了下我的目录,并没有/usr/lib/libraw1394.so ,只有/usr/lib/libraw1394.so.11 和/usr/lib/libraw1394.so.11.0.1,
请问,是应该把sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8 中前面路径中的/usr/lib/libraw1394.so 的给改了么?
- wjchen
- 帖子: 583
- 注册时间: 2011-05-02 19:08
- 系统: ubuntu 12.04
Re: 求教,遇到bash: syntax error near unexpected token 的问题
是的,改成/usr/lib/libraw1394.so.11 或/usr/lib/libraw1394.so.11.0.1是应该把sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8 中前面路径中的/usr/lib/libraw1394.so 的给改了么
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
试了下还是不行啊,在root用户下输入了wjchen 写了:是的,改成/usr/lib/libraw1394.so.11 或/usr/lib/libraw1394.so.11.0.1是应该把sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8 中前面路径中的/usr/lib/libraw1394.so 的给改了么
ln -s /usr/lib/libraw1394.so.11.01 /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8
回到matlab
运行 unix('ffmpeg')
还是ffmpeg: error while loading shared libraries: libraw1394.so.8: cannot open shared object file: No such file or directory
ans =
127
。。。
这是为什么。。。
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
改了连接后,我运行:[s,d]=unix('ffmpeg')wjchen 写了:是的,改成/usr/lib/libraw1394.so.11 或/usr/lib/libraw1394.so.11.0.1是应该把sudo ln -s /usr/lib/libraw1394.so /usr/local/MATLAB/R2010b/sys/os/glnx86/libraw1394.so.8 中前面路径中的/usr/lib/libraw1394.so 的给改了么
错误:
s =
1
d =
ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
这是什么问题?我缺少glibcxx?
多谢多谢!
- wjchen
- 帖子: 583
- 注册时间: 2011-05-02 19:08
- 系统: ubuntu 12.04
Re: 求教,遇到bash: syntax error near unexpected token 的问题
ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
这是什么问题?我缺少glibcxx?
多谢多谢!
打开matlab,输入mbuild -setup,选择第一项,然后再试试。
如果不行,可以再试试把/usr/local/MATLAB/R2010b/sys/os/glnx86/中以libstdc++.so开头的文件暂时移开,重启matlab再试试。
还有第三种办法,用/usr/lib/i386-linux-gnu/libstdc++.so.6.0.16(不知你这里是不是这个路径和版本)替换/usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6这个软链接的指向目标。
哦忘了说了,如果你是64位的应该改成glnx64……
-
- 帖子: 17
- 注册时间: 2012-02-14 16:34
Re: 求教,遇到bash: syntax error near unexpected token 的问题
哥们,你是神!移除的方法是好用的!wjchen 写了:ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
ffmpeg: /usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/i386-linux-gnu/libjack.so.0)
这是什么问题?我缺少glibcxx?
多谢多谢!
打开matlab,输入mbuild -setup,选择第一项,然后再试试。
如果不行,可以再试试把/usr/local/MATLAB/R2010b/sys/os/glnx86/中以libstdc++.so开头的文件暂时移开,重启matlab再试试。
还有第三种办法,用/usr/lib/i386-linux-gnu/libstdc++.so.6.0.16(不知你这里是不是这个路径和版本)替换/usr/local/MATLAB/R2010b/sys/os/glnx86/libstdc++.so.6这个软链接的指向目标。
哦忘了说了,如果你是64位的应该改成glnx64……
