如何使用QProcess启动Shell脚本? [英] How to start a Shell Script with QProcess?

查看:1362
本文介绍了如何使用QProcess启动Shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用QProcess启动Shell脚本?
Shell脚本有八个不同的命令,一些与其他没有。的参数。

How can I start a Shell Script using QProcess? The Shell Script has eight different commands in it, some with arguments others without.

我试图启动Shell脚本(使用Ubuntu 11.10) / p>

I tried to start the Shell Script with (using Ubuntu 11.10):

QProcess *Prozess = new QProcess();
Prozess->setWorkingDirectory(MainDirectory);
Prozess->start("/bin/sh", QStringList() << "Shell.sh");

但这不起作用,这意味着什么也没有发生。如何使它工作?

But this doesn't work, that means nothing happens. How to make it work?

推荐答案

代码很好。

由于某种原因,您的程序无法运行 / bin / sh 测试你是否可以运行 gedit 而不是?),或者 MainDirectory 变量有错误的目录路径该目录中不存在 Shell.sh (大写错误?./Shell.sh?),或者您没有足够的权限运行或修改目标目录/文件(它们是您拥有的吗?)。

Either your program can't run /bin/sh for some reason (test if you can run gedit instead?), or the MainDirectory variable has wrong directory path (debug it), or the Shell.sh does not exist in that directory (capitalization mistakes? What about "./Shell.sh"?), or you don't have enough privileges to run or modify target directory/files (are they owned by you?).

这篇关于如何使用QProcess启动Shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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