unterminated `s' command

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

My guess is you need to escape the apostrophes.

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

[code]Dim ssid As String = RunCommand(“awk -F= '/^ssid/{gsub(/ /,”""",$2);print $2}’ /etc/hostapd/hostapd.conf")

sed -i \‘s/MyPi
/PiFi/g\’[/code]

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