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
-1
votes
1 answer

What is the return type of a method that returns Heredoc?

I have some PHP code that looks like this: class MyClass { public static function classPhpdoc($paramA) { return <<
Radu Murzea
  • 10,724
  • 10
  • 47
  • 69
-1
votes
1 answer

How to solve my error in this shell script

I have been trying to run the following command but it gives me the following error but when I type command in terminal it runs, how to fix this Command: host='' user='' pass='' path='path' srcfile='file.txt' lftp -u $user,$pass $host <<…
-1
votes
2 answers

EOF in expect script spawning sftp

I have a script that is transferring files from a linux server to a windows server. I want to log the data related to the transfers but EOF is giving me error in the HEREDOC construct. Can anyone show me the way forward for this. My script…
osia6028
  • 23
  • 6
-1
votes
1 answer

How to use multiple hostnames in single bash variable?

Working script for single host I sourced the following bash scripts inside .bashrc and is working fine with single hostname host1. I can do scp, rsync and other remote commands without any problem. But I want to use it for multiple hostnames eg.…
sai
  • 87
  • 8
-1
votes
1 answer

cat EOF issues with indentation

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…
uberrebu
  • 3,597
  • 9
  • 38
  • 73
-1
votes
1 answer

Create new file using heredoc in Bash

I'm sorry if anyone has already asked the question, I searched for it and have not yet found an answer. I need to create a new text file using heredoc by only one command line. What I have tried so far without success, something like this- cat << ""…
-1
votes
1 answer

How to expand env var in ANSI C-like string and use literal newline?

I am using herestring to pass a string (two input values with newlines) as standard input to an installer executable. For example, executing an installer with two inputs /var/tmp and yes #!/bin/bash # run_installer.sh ./installer <<<…
James Wierzba
  • 16,176
  • 14
  • 79
  • 120
-1
votes
2 answers

Illegal Characters in Password in Expect / Shell Script

We are having a password which is bt67nJuse3?{]=_0!\`fr,./&##@ (Except the quotes). This password contains characters such as {, `, /, ., ! which might need to be escaped. A lot of combinations have been tried to no avail and after spending a lot…
BejoyM
  • 63
  • 8
-1
votes
1 answer

Redirecting logs in shell script

Thanks for looking into my concern. I have a piece of code inside my shell script as shown below and want to redirect logs of below script to a file. could you please help with it. ssh -i /home/$cu/.ssh/${ssh_key}_rsa $Linux_User@$Linux_Machine…
Ras
  • 543
  • 1
  • 9
  • 25
-1
votes
1 answer

Is it possible to write javascript in php heredoc syntax?

I'm trying to output Javascript code heredoc syntax and I want it to be printed out with the PHP print_r function. Is it possible to do that? PHP: "; print_r($val); echo ""; } $str = <<
black_yurizan
  • 407
  • 2
  • 7
  • 19
-1
votes
1 answer

PHP return method from an included page?

I would like to implement translation on a website and I'm trying out the method found at http://we-love-php.blogspot.com.ar/2012/07/how-to-implement-i18n-without.html I can do it with ease when the page requested is a complete page but I don't know…
CesarA
  • 85
  • 1
  • 7
-1
votes
2 answers

How to create php file using php

I'm trying to create multiple .php files using php itself. I want to put some code into a file; most of code is the same but only one or two variables that I wanted to be dynamic. I mean every file that I make are exactly like each other the only…
Mr.5hady
  • 57
  • 6
-1
votes
2 answers

Why is my Perl script giving the error "Can't find string terminator " _HTML_" anywhere before EOF"?

Hi I have just added an IF condition into my source and since then i am getting the error "Can't find string terminator _HTML_ anywhere before EOF " But it works if I remove the IF I am new to both Perl and CGI and I do not know how to resolve…
Saurabh Sharma
  • 2,422
  • 4
  • 20
  • 41
-2
votes
1 answer

Here Document in PHP

How do you call an input tag in a here document when that here document is in a variable in php? Here is my code: Generate ASCII Table
-2
votes
1 answer

Unable to print multiline output with HEREDOC php by using XAMPP

I'm not able to print php multiline output with the "<<<" command using XAMPP. This is the code I'm trying to run:
tiagh3tto
  • 1
  • 1
1 2 3
50
51