quoting

Running shell command that has nested quotes via ssh

泪湿孤枕 提交于 2019-11-27 15:51:01
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/ | \ awk 'BEGIN{print "DISK", "%USAGE", "STATUS"} {split($5, a, "%"); \ var="GREEN"; print $1, $5, var}' |

How to pass arguments with special characters to call shell script

我与影子孤独终老i 提交于 2019-11-27 15:24:34
Calling .sh(shell script) with the required parameters as below :- sh home/example.sh --context_param dbUserName=username --context_param dbPassword=exam!ple##### --context_param resultDate=2017-01-13 calling example.sh with paramters dbUsername and password but getting following error:- -bash: !ple#####: event not found I think special characters restrict the command to execute. Then how i have to pass the special characters. Any help will be appreciable. Change the line, dbPassword=exam!ple##### to, dbPassword='exam!ple#####' to avoid ! (history-expansion) being treated specially in bash

How to put double quotes in VS2010 post build step

故事扮演 提交于 2019-11-27 14:54:04
问题 I'm trying to create a post build file copy step in VS2010 which handles path macros when they have embedded spaces. I've tried surrounding the copy commands in double quotes but I get error from when copy is invoked if $(SolutionDir) contains a space. the echoed command line in the error message does not show the double quotes. copy "$(SolutionDir)$(Configuration)\*" "$(TargetDir)" I also tried separately \" and "" but both of these cause the 2 character escape sequence to appear in the

bash quotes in variable treated different when expanded to command

心已入冬 提交于 2019-11-27 14:32:36
Explaining the question through examples... Demonstrates that the single-quotes after --chapters is gets escaped when the variable is expanded (I didn't expect this): prompt@ubuntu:/my/scripts$ cat test1.sh #!/bin/bash actions="--tags all:" actions+=" --chapters ''" mkvpropedit "$1" $actions prompt@ubuntu:/my/scripts$ ./test1.sh some.mkv Error: Could not open '''' for reading. And now for some reason mkvpropedit receives the double quotes as part of the filename (I didn't expect this either): prompt@ubuntu:/my/scripts$ cat test1x.sh #!/bin/bash command="mkvpropedit \"$1\"" command+=" --tags

Python module to shellquote/unshellquote? [duplicate]

爱⌒轻易说出口 提交于 2019-11-27 13:29:16
This question already has an answer here: How to escape os.system() calls? 10 answers Is there anything in the Python standard library that will properly parse/unparse strings for using in shell commands? I'm looking for the python analog to perl's String::ShellQuote::shell_quote : $ print String::ShellQuote::shell_quote("hello", "stack", "overflow's", "quite", "cool") hello stack 'overflow'\''s' quite cool And, even more importantly, something which will work in the reverse direction (take a string and decompose it into a list). pipes.quote is now shlex.quote in python 3. It is easy enough to

Write CSV To File Without Enclosures In PHP

血红的双手。 提交于 2019-11-27 12:17:27
Is there a native function or solid class/library for writing an array as a line in a CSV file without enclosures? fputcsv will default to " if nothing is passed in for the enclosure param. Google is failing me (returning results for a whole bunch of pages about fputcsv ), and PEAR's libraries do more or less the same things as fputcsv . Something that works exactly like fputcsv , but will allow the fields to remain unquoted. currently: "field 1","field 2",field3hasNoSpaces desired: field 1,field 2,field3hasNoSpaces The warnings about foregoing enclosures are valid, but you've said they don't

How do I pass on script arguments that contain quotes/spaces?

五迷三道 提交于 2019-11-27 02:06:40
问题 I'm trying to write a script notify-finish that can be prepended to any command. When done, it will run the command given by the arguments following, then email the user when the command is complete. Here's what I have: PROG=$1 # Run command given by arguments $@ ECODE=$? echo -e "Subject: `hostname`: $PROG finished\r\nTo: <$USER>\r\n\r\nExited with $ECODE\r\n" | sendmail $USER This works most of the time, but when arguments contain spaces, the quoting is stripped off. Working example: notify

What Vim command(s) can be used to quote/unquote words?

老子叫甜甜 提交于 2019-11-26 23:47:23
问题 How can I quickly quote/unquote words and change quoting (e.g. from ' to " ) in Vim? I know about the surround.vim plugin, but I would like to use just Vim. 回答1: surround.vim is going to be your easiest answer. If you are truly set against using it, here are some examples for what you can do. Not necessarily the most efficient, but that's why surround.vim was written. Quote a word, using single quotes ciw'Ctrl+r"' ciw - Delete the word the cursor is on, and end up in insert mode. ' - add the

Bash command quoting issue

筅森魡賤 提交于 2019-11-26 23:37:27
问题 I have this weird issue, I can't understand why is happening. It should be a piece of cake for any bash ninja. OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'" unison $OPTIONS a b I expected this to be translated as... unison -auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three' a b ...and just work. But it doesn't. When running the full command, I have no problems, unison is ok with that. But when I run the command unison $OPTIONS a b ,

Setting Public Property Values on the Command Line

谁说我不能喝 提交于 2019-11-26 21:45:33
问题 Setting Public Property Values on the Command Line of an msi follows the pattern MyInstaller.msi PUBLICPROPERTY="someValue" This works on "Command Prompt" aka cmd.exe and powershell. But MyInstaller.msi PUBLICPROPERTY="" does not work like expected in powershell. I expected that it sets PUBLICPROPERTY to null but it sets PUBLICPROPERTY to the value "CURRENTDIRECTORY="C:\temp\msi\"" (it does work like expected with cmd.exe). Why do powershell and cmd.exe behaviour different, and how can it be