Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to add options to "command" ?
Forum Updated to NodeBB v4.3 + New Features

How to add options to "command" ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
expect
2 Posts 2 Posters 264 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    When I use :terminal I can type in this :
    bluetoothctl scan on

    I can also pass a single char array to my function (command) and it works as expected.
    I need to pass "options" to the main command.

    I have done this before but forgot why and how to actually make the command
    same as typed on terminal .

    char command[32] ="bluetoothctl scan on ";

    does nor work - the actual "system call "
    expects list of parameters / options

    QP->start("/bin/sh", QStringList() << "-c" << command);'

    My poor attempt to solve this did not pass by compiler

     char command[32] ="bluetoothctl";
        char add[32] = " scan ";
        char more_add[32] = " on";
     //   command += "scan ";
     //   command += "on";
    
        command += add;
        command += more_add;
    
        //Iterator next
        result =  BTUL->ProcessCommand(command,verify[1]);
    

    PS I did search for "command" , my past post , but it came empty..

    sierdzioS 1 Reply Last reply
    0
    • A Anonymous_Banned275

      When I use :terminal I can type in this :
      bluetoothctl scan on

      I can also pass a single char array to my function (command) and it works as expected.
      I need to pass "options" to the main command.

      I have done this before but forgot why and how to actually make the command
      same as typed on terminal .

      char command[32] ="bluetoothctl scan on ";

      does nor work - the actual "system call "
      expects list of parameters / options

      QP->start("/bin/sh", QStringList() << "-c" << command);'

      My poor attempt to solve this did not pass by compiler

       char command[32] ="bluetoothctl";
          char add[32] = " scan ";
          char more_add[32] = " on";
       //   command += "scan ";
       //   command += "on";
      
          command += add;
          command += more_add;
      
          //Iterator next
          result =  BTUL->ProcessCommand(command,verify[1]);
      

      PS I did search for "command" , my past post , but it came empty..

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      What is BTUL and how does it work?

      If you ask about QProcess, then something like this should work:

      QProcess process;
      process.start("bluetoothctl", {"scan", "on"});
      

      Qt will insert spaces between arguments automatically.

      (Z(:^

      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