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. Cannot connect to wifi name has character represented
Forum Updated to NodeBB v4.3 + New Features

Cannot connect to wifi name has character represented

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 474 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.
  • H Offline
    H Offline
    hooanghiep
    wrote on 3 Jun 2019, 08:21 last edited by
    #1

    i am trying to connect wifi by using nmcli. When wifi name has character represented then i got error:
    Syntax error: Unterminated quoted string
    here is my code:

    void WifiThread::connectWifi(QString strName, QString strPassword) 
    {
        QString strTmp = QString("nmcli --wait 20 device wifi connect \"%1\" password \"%2\" 2>&1").arg(strName, strPassword);
            QByteArray ba = strTmp.toUtf8();
            const char *pCommand = ba.data();
            system(pCommand);
    }
    

    thank you so much for your help.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Jun 2019, 08:29 last edited by
      #2

      Hi,

      What characters are causing trouble ?
      Why not use QProcess ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • H Offline
        H Offline
        hooanghiep
        wrote on 3 Jun 2019, 10:58 last edited by
        #3

        all characters in this link: https://www.austincc.edu/rickster/COSC1320/handouts/escchar.htm

        J 1 Reply Last reply 3 Jun 2019, 11:43
        0
        • H hooanghiep
          3 Jun 2019, 10:58

          all characters in this link: https://www.austincc.edu/rickster/COSC1320/handouts/escchar.htm

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 3 Jun 2019, 11:43 last edited by jsulm 6 Mar 2019, 11:43
          #4

          @hooanghiep You need to escape such characters, like

          nmcli --wait 20 device wifi connect \"abcd\\\"efg\" password ...
          

          First 2 backslashes are there to put a backslash into your string, third one is to escape " in C++.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply 4 Jun 2019, 02:03
          1
          • J jsulm
            3 Jun 2019, 11:43

            @hooanghiep You need to escape such characters, like

            nmcli --wait 20 device wifi connect \"abcd\\\"efg\" password ...
            

            First 2 backslashes are there to put a backslash into your string, third one is to escape " in C++.

            H Offline
            H Offline
            hooanghiep
            wrote on 4 Jun 2019, 02:03 last edited by hooanghiep 6 Apr 2019, 02:03
            #5

            @jsulm how about these characters: "\", " ' ", "?"
            thanks for your answer. :)

            J 1 Reply Last reply 4 Jun 2019, 04:23
            0
            • H hooanghiep
              4 Jun 2019, 02:03

              @jsulm how about these characters: "\", " ' ", "?"
              thanks for your answer. :)

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 4 Jun 2019, 04:23 last edited by
              #6

              @hooanghiep said in Cannot connect to wifi name has character represented:

              how about these characters

              It's same for all characters which needs to be escaped in a shell.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              1/6

              3 Jun 2019, 08:21

              • Login

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