unterminated `s' command

  1. 3 months ago

    Scott R

    May 9 Pre-Release Testers, Xojo Pro

    I am receiving a sed: -e expression #1, char 11: unterminated `s' command error when executing this command.

    Dim cmd As String =  "sed -i 's|ssid=" + Session.Settings.ssid + "|ssid=" + ssid + "|g' /etc/hostapd/hostapd.conf"
    c = RunCommand(cmd)

    If i execute the command directly in the CLI, I get no error. It works fine.

    sed -i 's|ssid=MyPi|ssid=PiFi|g' /etc/hostapd/hostapd.conf

    I found the issue. It appears when execute this statement top populate the Session.Settings.ssid property, a carriage return is appended.

    Dim ssid As String = RunCommand("awk -F= '/^ssid/{gsub(/ /,"""",$2);print $2}' /etc/hostapd/hostapd.conf")
    
    sed -i \'s/MyPi
    /PiFi/g\'

    If I strip the last character from the returned string, it works fine.

    sed -i 's/ssid=PiFi/ssid=MyPi/g' /etc/hostapd/hostapd.conf
  2. Markus W

    May 9 Pre-Release Testers #JeSuisHuman New Zealand, Auc...

    My guess is you need to escape the apostrophes.

  3. Scott R

    May 13 Pre-Release Testers, Xojo Pro Answer
    Edited 3 months ago

    I found the issue. It appears when execute this statement top populate the Session.Settings.ssid property, a carriage return is appended.

    Dim ssid As String = RunCommand("awk -F= '/^ssid/{gsub(/ /,"""",$2);print $2}' /etc/hostapd/hostapd.conf")
    
    sed -i \'s/MyPi
    /PiFi/g\'

    If I strip the last character from the returned string, it works fine.

    sed -i 's/ssid=PiFi/ssid=MyPi/g' /etc/hostapd/hostapd.conf

or Sign Up to reply!