Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Writing commands to linux bash
Forum Updated to NodeBB v4.3 + New Features

Writing commands to linux bash

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 5 Posters 5.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JonBJ JonB

    @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.

    devDawgD Offline
    devDawgD Offline
    devDawg
    wrote on last edited by
    #21

    @JonB You may think it is overkill, and you are probably right, but it accomplishes what I need. For the meantime, I will settle for this so I can focus on other tasks at hand.

    I really appreciate your patience and willingness to help, thank you @JonB !

    Anything worthwhile is never achieved easily.

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved