heredoc

How do I write the <<<TOC thing in PHP?

99封情书 提交于 2019-12-11 17:57:59
问题 I forgot how to write the one command that looked something like this <<TOC bla bla bal bal TOC; how was it written again? 回答1: These are called heredocs. 回答2: It works like this: $foo = <<<TOKEN multi line string TOKEN; TOKEN can be anything you want as long as you being and end the heredoc with the same exact thing. 回答3: Yes that is corect syntax for using a heredoc, however make sure that TOC; line is not indented or it will not work. FYI you can call it anything you want such as HTML not

cat EOF issues with indentation [duplicate]

江枫思渺然 提交于 2019-12-11 14:17:22
问题 This question already has answers here : here-document gives 'unexpected end of file' error (5 answers) Multi-line string with extra space (preserved indentation) (7 answers) Closed 8 months ago . NOTE: If anyone feel this question has been answered before please paste your answer below otherwise please don't interfere with people trying to help someone who needs help. Thanks I am not sure why it is such an hassle trying to cat content to file when the content is indented Can anyone point to

Heredoc this PHP-HTML

[亡魂溺海] 提交于 2019-12-11 13:44:09
问题 I'm trying to heredoc the following code: <?php //some php //some more php if (some condition) { ?> <label>CMKS1<?php echo $CMKS1_CMKS2_space; ?>CMKS2</label> <input name="cmks1" type="text" class="base-cls <?php if ($err1) echo "err-cls"; ?>" /> <input name="cmks2" type="text" class="base-cls <?php if ($err2) echo "err-cls"; ?>" /> <?php }//if //some final php here ?> but I'm stuck on the $CMKS1_CMKS2_space variable on the label line and the 2 if conditional statements in input name cmks1

use sed to in-place replace a line in a file with multiple lines from stdin or HEREDOCs

与世无争的帅哥 提交于 2019-12-11 08:02:31
问题 I want to replace a line in a file with multiple lines. I know I can use \n in the sed replace, but that is rather ugly. I was hoping to HEARDOCs. So I can do this to replace the line with multiple lines: $ cat sedtest DINGO=bingo $ sed -i -e "s/^DINGO.*$/# added by $(whoami) on $(date)\nDINGO=howdy/" sedtest $ cat sedtest # added by user on Sun Feb 3 08:55:44 EST 2019 DINGO=howdy In the command I want to put the replacement in new lines so it's easier to read/understand. So far I have been

Why Sqlplus bash script NOT returning error for ORA-02291 integrity constraint when “WHENEVER SQLERROR EXIT 1” is used?

你离开我真会死。 提交于 2019-12-11 06:16:55
问题 I have written a bash script to connect to sqlplus and execute all the sql scripts in a particular folder. Below is the execute method of the script. execute() { if [ ! -d "$DIR_SqlFiles" ] then echo "No sql files were found. Cannot find path ${DIR_SqlFiles}" return 1 fi echo "`date` :Connecting To ${userName}/******@${serviceName}"; for file in `ls ${DIR_SqlFiles}/*` ; do echo "`date` :Executing file $file..." echo "`date` :SQL OUTPUT:"; sqlplus -s ${userName}/${password}@${host}:${port}/$

Trying to write a heredoc into an existing file using Sed in bash

那年仲夏 提交于 2019-12-11 05:47:12
问题 I'm attempting to write a heredoc at the top of my php.ini file directly under the [PHP] line. I'm also attempting to do it assuming the following conditions: [PHP] might not be at the very top (in other use cases, it would be nice to know how to put a heredoc anywhere in a file after something, so specifying 'line 2' isn't really useful The heredoc has to be contained in the file. No use of sed where another file is opened and read into the existing file Assume there is only one instance of

Using <<<CON in PHP

陌路散爱 提交于 2019-12-11 04:47:22
问题 What is the effect of the following code? $page = <<<CON <p><center>Blah blah blah</center></p> CON; What does the <<<CON do? 回答1: This is known as heredoc. It's essentially a way of defining the value of a variable that spans multiple lines, and doesn't require escaping like traditional strings. The "CON" part is merely an identifier that represents the start and end of the value. This can be changed to a more familiar value. $str = <<<EOD Example of string spanning multiple lines using

How can heredocs be used with xargs?

左心房为你撑大大i 提交于 2019-12-11 04:26:52
问题 Background I'm looking to strip any # TODO comments from some python source code files output by git archive before sending it off. I'm looking to do so from a script that will be run from a variety of *nix OSes, so it should be as POSIX-compliant as possible. I'm aware that find -print0 and xargs -0 aren't in the base spec, but they appear to be common enough that I'm fine with using them (unless a better alternative exists). I'm using ed due to sed -i not being in the base spec for in-place

JQuery inside here-doc not working

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:33:04
问题 Is it possible to include JQuery in the here-doc section of perl. I tried but no success. Here is my code. my $cgi = CGI->new();print header();print start_html("JQuery in perl"); print <<JS; <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script><!-- $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); //--></script> <p>Click to hide</p> <p>Click to hide</p> <p>Click to hide</p> </body> JS print end_html(); But when I write a

How to bind data in heredoc of scala?

爷,独闯天下 提交于 2019-12-10 18:47:20
问题 val name = "mike" val str = """Hi, {name}!""" println(str) I want it output the str as Hi, mike! , but failed. How to do this? 回答1: Scala does not support string interpolation. There is a compiler plugin that implements it at http://github.com/jrudolph/scala-enhanced-strings. Without the plugin you can use concatenation or format strings: val str = name formatted "Hi, %s!" or of course val str = "Hi, %s!".format(name) 回答2: A total hackish solution would be to use Scala's XML interpolation: