How to execute a bash command stored as a string with quotes and asterisk [duplicate]

Have you tried: eval $cmd For the follow-on question of how to escape * since it has special meaning when it’s naked or in double quoted strings: use single quotes. MYSQL=’mysql AMORE -u username -ppassword -h localhost -e’ QUERY=”SELECT “‘*'” FROM amoreconfig” ;# <– “double”‘single'”double” eval $MYSQL “‘$QUERY'” Bonus: It also reads nice: eval mysql … Read more

Powershell: passing json string to curl

Try using the –% operator to put PowerShell into simple (dumb) argument parsing mode: curl.exe –% -ku user@email:mypass -X PUT -d “data={\”password\”:\”keypass\”}” https://build.phonegap.com/api/v1/key This is quite often useful for invoking exes with argument syntax that runs afoul of PowerShell’s argument syntax. This does require PowerShell V3 or higher.

String.replaceAll single backslashes with double backslashes

The String#replaceAll() interprets the argument as a regular expression. The \ is an escape character in both String and regex. You need to double-escape it for regex: string.replaceAll(“\\\\”, “\\\\\\\\”); But you don’t necessarily need regex for this, simply because you want an exact character-by-character replacement and you don’t need patterns here. So String#replace() should suffice: … Read more

Unescape HTML entities in JavaScript?

Most answers given here have a huge disadvantage: if the string you are trying to convert isn’t trusted then you will end up with a Cross-Site Scripting (XSS) vulnerability. For the function in the accepted answer, consider the following: htmlDecode(“<img src=”https://stackoverflow.com/questions/3700326/dummy” onerror=”alert(/xss/)”>”); The string here contains an unescaped HTML tag, so instead of decoding anything … Read more

How to escape apostrophe (‘) in MySql?

The MySQL documentation you cite actually says a little bit more than you mention. It also says, A “’” inside a string quoted with “’” may be written as “””. (Also, you linked to the MySQL 5.0 version of Table 8.1. Special Character Escape Sequences, and the current version is 5.6 — but the current … Read more