heredoc

Makefile recipe with a here-document redirection

拥有回忆 提交于 2020-01-03 10:42:12
问题 Does anyone know how to use a here-document redirection on a recipe? test: sh <<EOF echo I Need This echo To Work ls EOF I can't find any solution trying the usual backslash method (which basically ends with a command in a single line). Rationale: I have a set of multi-line recipes that I want to proxy through another command (e.g., sh, docker). onelinerecipe := echo l1 define twolinerecipe := echo l1 echo l2 endef define threelinerecipe := echo l1 echo l2 echo l3 endef # sh as proxy command

Can I use a heredoc to enter a password in bash?

若如初见. 提交于 2019-12-31 02:18:06
问题 I know about RSA authentication, but for my purposes I want to use a heredoc to specify the password. I want something like the following, but I can't get it to work. Is this even possible? #!/bin/bash echo -n "Enter Password: " read -s password ssh myhost << EOL $password echo "I'm logged onto myhost" EOL echo done This is what I get when I try it: $ ./testssh Enter Password: Pseudo-terminal will not be allocated because stdin is not a terminal. user@myhost's password: Warning: No xauth data

Have I misunderstood what heredoc should do?

[亡魂溺海] 提交于 2019-12-31 02:13:23
问题 I'm very new to PHP so I know I am missing something obvious here - I thought the heredoc function is supposed to retain formatting, line breaks, etc. But whenever I test it, while it parses, there is no formatting. I've tried lots of different scripts including copy-and-pasts from sources such as PHP.net and W3schools - so I know there is nothing wrong with the scripts. Can't google up an answer to this one - probably because it's too obvious?? (BTW, testing with MAMP). Thanks. 回答1: HEREDOC

How to suppress variable substitution in bash heredocs

左心房为你撑大大i 提交于 2019-12-28 06:58:19
问题 Is it possible to create a heredoc that does not become subject to variable expansion? e.g. cat <<-EOF > somefile.sh Do not print current value of $1 instead evaluate it later. EOF Update I am aware of escaping by \ . My actual heredoc has many variables in it - and it is error prone and tedious to escape all of them. 回答1: Quote the delimiter: cat <<-"EOF" > somefile.sh Do not print current value of $1 instead evaluate it later. EOF This results in: $ cat somefile.sh Do not print current

Unable to use here-document delimited by EOF within phing XML

◇◆丶佛笑我妖孽 提交于 2019-12-25 09:15:27
问题 I have some commands to be run after switching to a different user. I need to do this in a build xml file. Following is what I have done - <exec command="sudo su auto_deploy << EOF echo 'Logged in user' whoami EOF" dir="${dir.scratchpad}" /> I have used XML escaping, i.e. < for < . However, I am getting the following error - sh: warning: here-document at line 0 delimited by end-of-file (wanted `EOF') Related question - here-document gives 'unexpected end of file' error Update Note - I have

How can I preserve / maintain consecutive newlines in Ruby here-document?

跟風遠走 提交于 2019-12-24 22:28:04
问题 I wonder how can I preserve consecutive newline characters with Ruby here-document? In my program all of them are collapsed to one newline. For example: s=<<END 1 2 3 4 END evaluates to: s="1\n2\n3\n4\n" However I would like to preserve the consecutive newlines when for example formatting a BBcode document a letter or something similar. 回答1: That looks like a bug to me. Have you tried a multiline %q ? s=%q(1 2 3 4 ) 来源: https://stackoverflow.com/questions/18157087/how-can-i-preserve-maintain

Running script with HERE_DOC method in background

喜夏-厌秋 提交于 2019-12-23 07:51:56
问题 I have a script that should be run in background. I must answer a question as soon as I run the bash..How can I do that? (nohup python script.py lst '<<HERE yes HERE' &) 回答1: The << heredoc is multiline, like somescript <<EOF & input EOF the heredoc delimiter should be alone on the final line You can use one line heredoc with <<< , like: somescript <<<"this coming from stdin" & 来源: https://stackoverflow.com/questions/25337304/running-script-with-here-doc-method-in-background

JavaScript Multiline String [duplicate]

余生长醉 提交于 2019-12-23 07:00:08
问题 This question already has answers here : Creating multiline strings in JavaScript (37 answers) Closed last year . The question is: What is the JavaScript method to store a multiline string into a variable like you can in PHP? 回答1: If by 'multiline string' you mean a string containing linebreaks, those can be written by escaping them using \n (for newline): var multilineString = 'Line 1\nLine 2'; alert(multilineString); // Line 1 // Line 2 If you mean, how can a string be written across

How to insert an inline (heredoc maybe? ) python script into a bash stdin/stdout streaming pipeline

孤者浪人 提交于 2019-12-21 21:01:14
问题 I have recently been doing fair amount of work in python and would like to be able to use its features instead of shell/bash builtins / shell scripting. So for a shell pipeline like this: echo -e "Line One\nLine Two\nLine Three" | (cat<<-HERE | python import sys print 'stdout hi' for line in sys.stdin.readlines(): print ('stdout hi on line: %s\n' %line) HERE ) | tee -a tee.out All that is printed is "stdout hi" What needs to be fixed here? thanks! 回答1: It would be better if you explained what

Can I access a variable within a heredoc in Ruby?

丶灬走出姿态 提交于 2019-12-21 06:46:55
问题 If I have a method def some_method p = {} string = <<-MY_TERMINATOR Example text blah blah lorem ipsum something or another MY_TERMINATOR end how can I access the variable p[:name] from within the heredoc? 回答1: You can interpolate just like in normal strings <<-TERMINATOR Example #{p[:name]} blah blah blah TERMINATOR 来源: https://stackoverflow.com/questions/3332849/can-i-access-a-variable-within-a-heredoc-in-ruby