Questions tagged [heredoc]

A Here-document is a special syntax of writing literal strings in sourcecode, used by different programming languages.

A heredoc or Here-Document is a way of writing literal strings in sourcecode. Many languages use heredocs: PHP, Perl, C#...

Although syntax can differ between programming languages, most heredocs start by putting a keyword, and end when the keyword is encountered as the only element on a line (no spaces, tabs or other characters are allowed). Perl example:

my $text = <<KEYWORD; #Any non-reserved word would do
This is some text.
It can contain $othervariables which will be replaced
Unless KEYWORD was between single quotes, in Perl.
KEYWORD
761 questions
0
votes
1 answer

Here document not executed in subshell in crontab

I have a script that works well from the prompt but not from crontab. The only thing that is broken is a here document ignored in a subshell in the script. The script uses psftp. Here is the code: /home/batch/myscript.sh: ( cd…
BenoitParis
  • 3,166
  • 4
  • 29
  • 56
0
votes
2 answers

Concatenating Content between Heredoc Tags

I am converting some formatted html text to a PDF file, and in doing so, I must place a table in the document. In order to put the table into the PDF correctly, I must use heredoc tags instead of regulars quotations (Came to this conclusion through…
user1440197
0
votes
1 answer

Php nowdoc (heredoc without parsing) is interpreting HTML Markup Characters - Not Desireable

I have PHP that looks like this: $func_code = <<<'EOT' foo1 foo2 ''. foo4 . '
'; EOT; echo $func_code; And the output looks like this: one_half foo1 foo2 ''. foo4 . ''; foo1 foo2 ''. foo4 . ''; As you can see, and are both…
JamesHoux
  • 2,999
  • 3
  • 32
  • 50
0
votes
2 answers

PHP Why Can't EOM contain PHP functions?

Possible Duplicate: Calling PHP functions within HEREDOC strings I am using Swiftmailer PHP to create an order complete page. When the customer lands on this page, I use an include to a PHP file. This page file has SwiftMailer EOM HTML that gets…
TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209
0
votes
1 answer

heredoc script issue with gdb

I want to write a shell script to help me start gdb and input some commands which I don't want to input by myself, how should I do that? I tried the heredoc below, but it doesn't work, what did I do wrong? #! /bin/sh - gdb ./myexe << MYHEREDOC b…
user1726366
  • 2,256
  • 4
  • 15
  • 17
0
votes
2 answers

Class function echos output inside heredoc string, but in wrong place

I'm trying to use a heredoc string in one section of my script, and inside this heredoc string is a function from inside a class that inputs some dynamic bit of stuff. The function outputs the code correctly... but in the wrong place. Here's what I…
jdstankosky
  • 657
  • 3
  • 15
0
votes
0 answers

using static::member->method inside HEREDOC

static public function toolBar() { var_dump(static::$_lang); var_dump(static::$_lang->getVal('Index')); return <<< EOC {${static::$_lang->getVal('Index')}} | 
vintox
  • 55
  • 8
0
votes
1 answer

heredoc with eval code execution

I've tryed a couple of methods to try and get this working but with no luck! I've got a page like this (Example):

blah blah

blah blah blah blah blah blah blah blah…

johnnnnnnnnnnnnnnny
0
votes
2 answers

Use return value of function call in PHP heredoc in Yii?

I'm trying to html encode a string that will be used as a tooltip in a google map. $cs = Yii::app()->getClientScript(); $cs->registerScript('someID', <<
User
  • 62,498
  • 72
  • 186
  • 247
0
votes
1 answer

How make an "here document" in Ant?

How to write an Ant script as: ... ... begin of HERE DOCUMENT > ./outfile.txt xxx toto yyy zzz end of HERE DOCUMENT ... ... Of Whom the execution creates a file called ./outfile.txt Whom contains: xxx toto yyy zzz
pindare
  • 2,382
  • 6
  • 21
  • 24
0
votes
0 answers

Store php form output to variable

I have successfully written a dynamic form with output of the form and data posted to mysql. What I'd like to do now is save the output of my php to a variable which I can then pass to html2pdf for pdf generation. I've tried to outline my current…
user1459766
  • 118
  • 2
  • 3
  • 16
0
votes
1 answer

PHP alternative to loop inside a HEREDOC

I am trying to create loop inside of a HEREDOC in php. I know that it is not possible to do so, but it was the best way for me to tell what I need help for.. This is my code: prepare("SELECT field1, field2 FROM table WHERE id =…
Corfitz.
  • 1,864
  • 3
  • 31
  • 53
-1
votes
1 answer

Conditional Terraform Output with heredoc

Using Terraform 1.1.4, I'm trying to output the result of a file creation in Terraform and want to use a conditional to skip this output if a variable evaluates as false. This is simple to do in the traditional sense but when using heredoc, I'm…
display name
  • 320
  • 1
  • 11
-1
votes
1 answer

What is "delimited by end-of-file (wanted `EOF')"

I am trying to execute following lines- sh """ #!/bin/bash cd ${WORKSPACE} cat << EOF > build.sh #!/bin/bash mkdir wsbuildlinux cd wsbuildlinux cmake3 ../../wiresharkbuild_linux make EOF …
sara
  • 15
  • 5
-1
votes
2 answers

How To Handle Multiple Lines within a Command Block in Terraform

I have a task whereby which I have to create a Harness Delegate in Terraform, and it has to be modularized and handled by GitHub Actions. As a result, my main TF is basically trying to tar a file, which makes a kubernetes-harness-delagate folder in…
R. Barrett
  • 685
  • 11
  • 34