I am trying to call tar
from a Qt
project:
QProcess::execute("/bin/su", {"-", "user", "-c", "\'/bin/tar xpf /tmp/smt.tbz2 -C /tmp\'"})
Bit I am getting:
-su: /bin/tar xpf /tmp/smt.tbz2 -C /tmp: No such file or directory
It looks like the su
command does not interpret correctly the command after -c
.
I think the problem is that you are quoting the command to run explicitly: QProcess
goes to some lengths to ensure parameters are passed as-is rather than being split any further.
Instead try...
QProcess::execute("/bin/su", {"-", "user", "-c", "/bin/tar xpf /tmp/smt.tbz2 -C /tmp"});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.