Score:0

Creating a folder from QML with /bin/sh -c mkdir

dz flag

Hi I'm trying to create a folder from QML with a QProcess call:

qproc.start("/bin/sh -c 'mkdir -p /tmp/x'");

It doesn't do anything. Nor does it return any error. From what I read, this syntax should be correct, is it ? Might it be permission issue ? How can check this ?

I tried to run the following one in order to know who was the running user of qml script:

qproc.start(/bin/sh -c 'whoami &> \"/tmp/mlog.txt\"'");

but the output file is not created...

Where should I look at ?


Context: this QML script is a user-extension for the MuseScore application running as AppImage. I have no access to the backend. I have to stay in a pure QML solution.

hr flag
It [looks like](https://doc.qt.io/qt-6/qprocess.html#start) the second argument should be a QtStringList i.e. something like `qproc.start("/bin/sh", { "-c", "mkdir -p /tmp/x"})`
hr flag
... your second attempt has some additional issues I think (1) the `&>` redirection is a bashism and (2) the literal quotes
lvr123 avatar
dz flag
As I'm in pure QML, a QStringList must be written with `[]`(javascript-style) and not `{}` (which is C#-style). For some reason, in my MuseScore environment `QProcess.start(command, arguments)` returns and error. The key was, as you mentioned, in the quotes (and the `&>` for the second command).
Score:0
dz flag

The key is in the quotes. The two expressions must be written like this, with quotes in that precise order.

qproc.start("/bin/sh -c \"mkdir -p '/tmp/x/'\"");

And

qproc.start("/bin/sh -c \"whoami > /home/vboxuser/Documents/log.txt\"");
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.