问题ProcessBuilder运行脚本sh [英] Problem ProcessBuilder running script sh

查看:407
本文介绍了问题ProcessBuilder运行脚本sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用以下代码执行脚本:

trying to execute an script, using this piece of code:

String command = "./myScript.sh";
pb = new ProcessBuilder(command, param1, param2);
pb.directory(directory);
pb.start();

我没有收到任何错误,但是没有出现假设的结果。无论如何,我尝试在终端中运行相同的命令,直接,并且一切正常。

我错过了什么?

I am not getting any kind of error, but neither the supposed results. Anyway, I tryed to run the same command, direclty in the terminal, and everything working correctly.
Am I missing something??

谢谢提前

推荐答案

问题不在于我调用脚本的方式,这是正确的。

但是它在剧本里面。起初它是:

The problem was not on the way I called the script, which was right.
But it was inside the script. At first it was:

#!/bin/bash
inputFolder=$1
outputFolder=$2 

cd $inputFolder

for file in `ls ` ; do
ffmpeg -i $inputFolder/$file -ar 22050 $outputFolder/$file.mp4 
done

但我找不到找不到ffmpeg命令,所以我将其更改为:

But I got ffmpeg command not found, so I changed it to:

#!/bin/bash
inputFolder=$1
outputFolder=$2 

cd $inputFolder

for file in `ls ` ; do
/usr/local/bin/ffmpeg -i $inputFolder/$file -ar 22050 $outputFolder/$file.mp4 
done  

带孔路径。但我仍然怀疑,为什么这是必要的,如果我在我的路径中有ffmpeg并且我在控制台直接执行任何目录?
如果有人可以给我一个答案,欢迎提供:)

with the hole path. But I have still doubts, why this is necessary, if I have ffmpeg in my path and I cand execute in console direclty form any directory?? If someone can give me an answer, it will be welcome :)

这篇关于问题ProcessBuilder运行脚本sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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