Linux 用“打开一个可执行文件”;上海";在Ubuntu下

Linux 用“打开一个可执行文件”;上海";在Ubuntu下,linux,bash,shell,ubuntu-14.04,Linux,Bash,Shell,Ubuntu 14.04,我正在使用Sonar()的API,它说,对于执行命令的函数,“该命令将使用sh executable执行。” 我想做的就是使用 tslint路径/to/my/code.ts 在终端中(因为这是有效的)。但是这个该死的方法去掉了带有“sh”的行,所以看起来像这样 sh tslint路径/to/my/code.ts 给了我一个错误 sh:0:无法打开tslint 即使命令以sh开头,我如何解决这个问题,以执行“tslint” 谢谢你的帮助 编辑:因为你们中的许多人问生成这个命令的java代码是什么样

我正在使用Sonar()的API,它说,对于执行命令的函数,“该命令将使用sh executable执行。”
我想做的就是使用

tslint路径/to/my/code.ts

在终端中(因为这是有效的)。但是这个该死的方法去掉了带有“sh”的行,所以看起来像这样

sh tslint路径/to/my/code.ts

给了我一个错误

sh:0:无法打开tslint

即使命令以sh开头,我如何解决这个问题,以执行“tslint”

谢谢你的帮助

编辑:因为你们中的许多人问生成这个命令的java代码是什么样子的(不是我的,它来自一个开源项目):

最终编辑:
工作版本:

Command command = Command.create("node");  
        command.addArgument(pathToTsLint);  
        command.addArgument("--format");  
        command.addArgument("json");  
        command.addArgument("--config");  
        command.addArgument(configFile);  
        command.addArgument(file.trim());  
        command.setNewShell(false);

哪个tslint
文件的完整路径签入终端。 从终点站你可以把它全部用上

/bin/sh-c”/path/to/tslint/path/to/my/code.ts“

通过声纳API,它是:

Command command = Comman.create('/full/path/name/to/tslint');
command.addArgument("--config " + configFile + " --format json " + file.trim()); 

您不需要来自
sh
命令的
-c
参数,但必须使用
tslint
命令的绝对路径。

您是否向该文件添加了权限“excute”?检查chmod命令请显示您尝试使用的代码。在shell中,您可以使用
sh-c'tslint path/to/my/code.ts'
,但不清楚如何使其适应您正在使用的API。
Command=Command.create(“tslint”)
command.addArgument(“--config”+configFile+”--format json”+file.trim())
所以我想要的是命令
tslint--config/path/to/my/config.json--format json/path/to/my/code.ts
,但是由于API,它会自动插入一个“sh”开始时。
sh-c'tslint--version'
工作并返回版本号,但是如果我尝试完整的命令
sh-c'tslint--config/home/vagrant/ASD-CDP/.sonar/tslint.json--format json/home/vagrant/ASD-CDP/cd portal ui/lib/ls2/utilities/modules installer/modules installer.ts'
我会听到乱码:@ManuelHuber lock更正了我的答案。我试过了:但得到了一个非常奇怪的错误:“单词出乎意料,预期”)?!什么Oo@ManuelHuber您是否为此命令设置了
命令。setNewShell(true)
?如果是,请将其设置为
false
。您好!是的,它设置为true,并将其设置为false是解决方案的一部分。我查看了它以及所有这些”setNewShell所做的是将“sh”添加到字符串中(在除windows以外的任何操作系统上)。现在在我们的服务器上运行的最终解决方案在我的原始帖子中。感谢您的帮助
Command command = Comman.create('/full/path/name/to/tslint');
command.addArgument("--config " + configFile + " --format json " + file.trim());