本文介绍了从八度/ MATLAB中运行bash脚本得到错误执行近意外的标记bash的语法错误'('的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的错误执行的bash语法附近意外的标记错误'('

我知道错误是造成在'),但我认为把这些命令在两者之间的是假设允许目录名的括号。我怎样才能解决这个不重命名的名字吗?

I know the error is caused by the ')' but I thought placing the commands in-between ' ' is suppose to allow the parenthesis in a directory name. How can I fix this without renaming the name?

在MATLAB /倍频code是:

The matlab / octave code is:

syscmd=strcat({'bash -c '},{''''},{'cd '},dirpathpls,newdirname,{' && exec bash xfade.sh'},{''''}) %used to run script to join files in stretch directory
system(syscmd);

和它产生下面是什么:

bash -c 'cd /tmp/h1/clients/04212015142432811_Fs_1000_ahh/pls/03sox_a_Fs_1000_ahh_(000_bit)_(0.0000
0sig_in_deg)_to_(508_bit)_(30.00000sig_in_deg) && exec bash xfade.sh'

请注意:
它正在从内部倍频3.8.1称为数学程序像MATLAB

please note:It's being called from inside octave 3.8.1 a math program like matlab

推荐答案

使用 中的bash命令行确实允许像使用保留字符没有逃避,但是,这是不是你在做什么,在一切你的 正在去世了抨击国米$ p $。 ptation,bash将不跨preting的 S作为命令的一部分,像这样的东西应该工作:

Using ' within a bash command line does allow the use of reserved characters like ( without escaping; however, that is not what you are doing. Everything within your 's is being passed to bash for interpretation, bash isn't interpreting the 's as part of the command. Something like this should work:

syscmd=strcat({'bash -c '},{''''},{'cd "'},dirpathpls,newdirname,{'" && exec bash xfade.sh'},{''''}) %used to run script to join files in stretch directory
system(syscmd);

我不知道MATLAB /倍频程,但我希望传达的想法。在要切实逃脱括号。唯一的缺陷存在,如果你的目录名可能有一个 $ 在里面,在这种情况下,或者你有 在你的目录名,事情会变得傻了。

I don't know matlab/octave, but I hope that conveys the idea. The " should effectively escape the parens. The only pitfall there is if your directory name might have a $ or " in it, in that case, or you have ' AND " in your dir name, things are going to get silly.

这篇关于从八度/ MATLAB中运行bash脚本得到错误执行近意外的标记bash的语法错误'('的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 17:28