Redis command line SET value containing double quotes - redis

I want to use redis command line (using redis-cli) to store json values. This is what I do
redis 127.0.0.1:6379> set test '{"a":"b"}'
This command fails with message :
Invalid argument(s)
I don't have problem with setting values that don't contain double quotes. What is the correct way to escape double quotes?

Add slashes to quotes
set test "{\"a\":\"b\"}"

We can use single quotes for storing the JSON value:
set name '{"a":"b"}'
Run get query like: get name
output : {"a":"b"}

later redis has fixed this problem. single quote works fine.

Related

Escape character within single quotes

I'm having an issue figuring out how to ignore signs and variables in a single quote string statement.
I am attempting to update a table with the new text with structure such as:
update xxx
set xxx =
'Our Ref. $BOOKING_NO$
.......
Kind regards'
If your $ chars are being interpreted, it isn't by Oracle ($ isn't special in Oracle anyway, and between single-quotes everything is a string), but rather by your client program or maybe shell script. If, for example, you are running this in SQL*Plus from a Unix-based shell script, you will need to use the appropriate means required by the shell you use to prevent the shell from interpreting $ and ' characters.

Pass quoted value sql plus param

I have a shell script script.sh, and a sql script modify_database.sql
In script.sh, I launch the sql script with some param using :
sqlplus user/password ... #modify_database.sql « param_id » « param_newValue »
And in the sql script, I get the parameters value with :
UPDATE T_TEST SET C1 = &param_newValue WHERE ID = &param_id
But I have a lot of problem with the « param_newValue » parameter.
In fact, this parameter could contain some spaces, slash, single quote and double quote character.
For example : L’avion du pilote était surnommé le « Redoutable »
I have a bunch of values to update.
Each new values are stored in a txt file, like that :
id;value
1; L’avion du pilote était surnommé le « Redoutable »
2; Another example of a « test » that’s it
How can I do to pass this param to sqlplus and set the value like that ? The quoted part is giving me a hard time :/
EDIT :
Example, in the input file I have :
123;;;"aaaa/vvvv/COD_039/fff=Avion d'office";"aaaa/vvvv/COD_039/fff=Hello d'orien";
I get this line, I do a cut command to get the first column (ID), the 4th column (to replace), and the 5th column (replacement).
I have a XML node, with a node which contain the 4th column text, and need to replace by the 5th column content.
So I do :
sqlplus -s $DBUSER/$DBPASSWORD#$DBHOST:$DBPORT/$DBSCHEMA #majConfXML.sql "$id" "$newcode"
update T_TEST set XML = updatexml(xmltype(XML_CONF),
'//A[#name="XXX"]//B[#name="YYY"]//pkValue','&2').getClobVal()
But in the param, there is some quotes.
So when I do the update request with '&2', the request is running but it does not work properly.
How can I escape/pass the param value into the updateXML request ?
Thank you
Finally, I find a problem in my bash script before the sqlplus call.
In fact, it was xargs command which I use who interpret simple quote. I simply add double quotes around each string with slash and quote in my input file.
Next, before calling sqlplus, I replace all “ ‘ “ (quote) by “ ‘’ “ (quote quote)

Escaping double quotes in TF2 scripting

In TF2 scripting, there is a simple command, echo. This simply logs a message to the console. It can be used with or without double quotes. However, I want to be able to log something to the console involving double quotes--say, the string He said, "nope.". In conventional programming, one would escape the quotes, as so:
echo "He said, \"nope.\""
However, in the TF2 console, this writes:
He said, \ nope.\
Is there a way to use quotes in echo and related commands? (E.g. say)
It's not possible to output double quotes using echo or say, only single quotes. (source) (In fact whenever you type double quotes into regular chat they're automatically changed into single quotes. I don't know why this limitation exists, I'd have to dig around.)
I know this is a very old thread, but in case anyone else is trying to find a fix for this and found this post, let me provide an example of how to use single quotes. I had an alias for switching crosshairs, as such:
alias "default" "cl_crosshair_blue 255; cl_crosshair_red 255; cl_crosshair_green 0; cl_crosshair_file "" "
This is to change the color of my crosshair, but more importantly, reset my crosshair to the "None" in options, letting the crosshair change depending on weapon, as I like most of the default crosshairs- but it would fail at the quotation mark immediately after "file", simply changing the colors and nothing more.
Using single quotes fixes this. Using ALT+0145 and ALT+0146 gives you the starting and ending single quotes (respectively) that you need. Replacing those two double quotes after "file" with the single quotes made the command work as intended.
alias "default" "cl_crosshair_blue 255; cl_crosshair_red 255; cl_crosshair_green 0; cl_crosshair_file ‘’ "
So anytime you absolutely need to use a set quotation marks twice in a command, just use single quotes.

how to escape a single quote in a pig script

Can pig scripts use double quotes? If not how to escape a single quote? I'm trying to parse a date time and I'm geting errors
Unexpected character '"'
And here is the script
logOutput = FOREACH parsedLog GENERATE uid, ToDate(timestamp,"YYYY-MM-DD'T'hh:mm ss:'00'") as theTime:datetime
You can escape a single quote using \\ (double backslash).
%declare CURRENT_TIME_ISO_FORMAT ToString($CURRENT_TIME,'yyyy-MM-dd\\'T\\'HH:mm:ss.SSSZ')
Just be aware that when you are using the escaping, you should not reuse the created String on another place of the script, but to everything on single call.
For example, let's say you want to send the String to the ISOToDay function, this script will fail:
%declare CURRENT_TIME_ISO_FORMAT ToString($CURRENT_TIME,'yyyy-MM-dd\\'T\\'HH:mm:ss.SSSZ')
%declare TODAY_BEGINNING_OF_DAY_ISO_FORMAT ISOToDay($CURRENT_TIME_ISO_FORMAT)
Instead, you should do:
%declare TODAY_BEGINNING_OF_DAY_ISO_FORMAT ISOToDay(ToString($CURRENT_TIME,'yyyy-MM-dd\\'T\\'HH:mm:ss.SSSZ'))
Have a try escaping them using \ and using single quotes.
logOutput = FOREACH parsedLog GENERATE uid, ToDate(timestamp,'YYYY-MM-DD\'T\'hh:mm ss:00') as theTime:datetime
Not sure what you mean with '00'.

inserting quotes in big query

I can easily upload a file delimited by ^
It looks something like...
CN^others^2012-05-03 00:02:25^^^^^Mozilla/5.0^generic web browser^^^^^^^^
CN^others^2012-05-03 00:02:26^^^^^Mozilla/5.0^generic web browser^^^^^^^^
But if I have a double quote somewhere, it fails with an error message...
Line:1 / Field:, Data between close double quote (") and field separator: field starts with:
Too many errors encountered. Limit is: 0.
CN^others^2012-05-03 00:02:25^^^^^"Mozilla/5.0^generic web browser^^^^^^^^
I do regulary get the files with "Mozilla as browser name, how do I insert data with double quotes?
Quotes can be escaped with another quote. For example, the field: This field has "internal quotes". would become This field has ""internal quotes"".
sed 's/\"/\"\"/g' should do the trick.
Note that in order to import data that contains quoted newlines, you need to set the allow_quoted_newlines flag to true on the import configuration. This means the import cannot be processed in parallel, and so may be slower than importing data without that flag set.