Writing commands to linux bash
-
@devDawg said in Writing commands to linux bash:
@JonB Holy moly.. It worked. Why the extra "-c" argument? Is this to denote console?
That's why UNIX provides
man bash
:)The simplest way to get any of the shells to execute a simple command is:
/bin/bash -c "the command as a single argument"
The
-c
says that a single argument follows of the entire command to be executed. Nothing to do with console.Your original code did not pass that, and instead tried to run a
bash
without that argument, and present the command to be executed on the shell's stdin (same as-s
argument). I am unsure why that did not in fact work, but using-c
is preferable in any case.It's good that this works now. But still a bit of overkill just to get a string sent to a device. I do think you should retry the "file" approach, but just use
QFile
(make sure you close it at the end) on/dev/ttyS0
instead of all that serial port code.wrote on 5 Jul 2018, 16:02 last edited by
21/21