quoting

Is > ever necessary?

旧巷老猫 提交于 2020-01-14 07:18:48
问题 I now develop websites and XML interfaces since 7 years, and never, ever came in a situation, where it was really necessary to use the > for a > . All disambiguition could so far be handled by quoting < , & , " and ' alone. Has anyone ever been in a situation (related to, e.g., SGML processing, browser issues, XSLT, ...) where you found it indespensable to escape the greater-than sign with > ? Update: I just checked with the XML spec, where it says, for example, about character data in

Write a query to select columns wrapped in single quotes

旧城冷巷雨未停 提交于 2020-01-06 14:21:10
问题 I am trying to write a select query which should return the column value wrapped in single quote. Say the column (ABC) has Values: 123 567 The query should return the Output: '123' '567' 回答1: While dealing with numerical data, you can simply concatenate. NULL values stay NULL . But for character data (or similar) that might need escaping, use proper functions. quote_nullable() or quote_literal() - depending on whether you have NULL values: SELECT quote_nullable(val) AS quoted_val FROM tbl;

PHP-generated javascript and quote marks

主宰稳场 提交于 2020-01-03 04:35:15
问题 I'm generating some javascript in my PHP code, and I need to assign some php variables to javascript variables. Unfortunately, sometimes my PHP variables contain quote marks. for instance: $foo = "'Dis here be a \"string\""; print "<script type='text/javascript'>var foo = '{$foo}';</script>"; will generate a javascript error because the resulting javascript will look like this: <script type='text/javascript'>var foo = '"'Dis here be a \"string\"'; I know I can use regexp on $foo to replace

psql passed variable

故事扮演 提交于 2020-01-02 12:39:29
问题 New to psql scripting. I try to pass a variable to a psql script but get an error: psql -v dateav="2012-01-28" mcdb -p 5555 -U admin -q -t -A -c 'select count (client_name) from v_activities where scheduled_start_date like :'dateav';' ERROR: syntax error at or near ":" LINE 1: ...) from v_activities where scheduled_start_date like :dateav; Any ideas? 回答1: Would work like this: echo "select count (client_name) from v_activities \ where scheduled_start_date like :'dateav'" | \ psql -v dateav=

General string quoting for TCL

谁说我不能喝 提交于 2019-12-31 19:37:20
问题 I'm writing a utility (which happens to be in python) which is generating output in the form of a TCL script. Given some arbitrary string variable (not unicode) in the python, I want to produce a TCL line like set s something ... which will set TCL variable ' s ' to that exact string, regardless of what strange characters are in it. Without getting too weird, I don't want to make the output messier than needed. I believe a decent approach is if the string is not empty and contains only

How to pass commands as arguments to ssh [duplicate]

拜拜、爱过 提交于 2019-12-31 07:36:13
问题 This question already has answers here : Running shell command that has nested quotes via ssh (3 answers) Double quotes inside quotes in bash (2 answers) Escaping quotes when using SSH (2 answers) Closed 2 years ago . My need is to make this command work: sshpass -p XXXX ssh -oStrictHostKeyChecking=no wsuser@192.168.0.100 sudo docker exec -u postgres postgres-container /bin/bash -c \" psql -d crawl-configuration -c 'select * from schema_version'\" But the result indicates that * is expanded

Creating an Array in Bash with Quoted Entries from Command Output

跟風遠走 提交于 2019-12-30 19:29:54
问题 I'm having trouble forming a bash array from a standard output. I've boiled it down to this minimal example: ~$ a=($(echo '1 2 3 "foo bar"')) ~$ echo ${a[0]} 1 ~$ echo ${a[1]} 2 ~$ echo ${a[2]} 3 ~$ echo ${a[3]} "foo ~$ echo ${a[4]} bar" I believe what is happening is that "foo and bar" are considered separate items in the standard output, but the goal would be to consolidate those items into one for the array. Obviously, I could write a small loop to consolidate these terms into one, but I'm

Creating an Array in Bash with Quoted Entries from Command Output

被刻印的时光 ゝ 提交于 2019-12-30 19:29:18
问题 I'm having trouble forming a bash array from a standard output. I've boiled it down to this minimal example: ~$ a=($(echo '1 2 3 "foo bar"')) ~$ echo ${a[0]} 1 ~$ echo ${a[1]} 2 ~$ echo ${a[2]} 3 ~$ echo ${a[3]} "foo ~$ echo ${a[4]} bar" I believe what is happening is that "foo and bar" are considered separate items in the standard output, but the goal would be to consolidate those items into one for the array. Obviously, I could write a small loop to consolidate these terms into one, but I'm

Escaping quotes when using SSH

大兔子大兔子 提交于 2019-12-29 07:35:26
问题 I'm trying to build a simple deployment script for my PHP apps. I know there are several tools for this job (Capistrano, Phing, etc.) but they seem like a lot of work for my simple deployment routine. I use sshpass to avoid typing my password over and over again. But after uploading my compressed installer, I need to ssh into the server and run some commands. One of which is sed. So, quotes are breaking my script. It's something like this: sshpass -p foo ssh user@host " cd /www/htdocs/foo/bar

Running shell command that has nested quotes via ssh

十年热恋 提交于 2019-12-28 04:27:07
问题 I have this following shell command: ssh user@host "df | grep /dev/ | \ awk 'BEGIN{print "DISK", "%USAGE", "STATUS"} {split($5, a, "%"); \ var="GREEN"; print $1, $5, var}' | column -t" I need to run this over ssh but I get syntax error due to the presence of nested double and single quotes. I tried the escape characters for before the beginning and ending of the quotes but it did not solve the problem. However, on local system running this will give the following output: $ df | grep /dev/ | \