Sponsored Content
Full Discussion: Information on heredoc
Top Forums Shell Programming and Scripting Information on heredoc Post 303010800 by jim mcnamara on Sunday 7th of January 2018 01:23:02 PM
Old 01-07-2018
Shell Command Language
This indicates that it writes to stdin by default.
Nested here documents example:

Code:
#!/bin/bash
$cat <<eofa; cat <<eofb
$>>test1
$>>test2
test1 
test2

$<<eofa; cat <<eofb
$>>test1
$>>test2

test2

In the second block the first instance does not have stdin defined as an output device, and so nothing is there to output or process the data "test1".

I think Don Cragun probably knows more.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Information

I'm new to unix and wanted to know if there are UNIX tools/programs on the market that can be loaded onto my laptop or external hard drive that I can use to practice and test what I'm learning. :) (2 Replies)
Discussion started by: Xman0ne
2 Replies

2. Shell Programming and Scripting

HEREDOC with fdisk

Hi folks What I'm trying is to build a partitioning script. I can pass a HEREDOC to fdisk just fine. Like this: fdisk /dev/sda << EOF p q EOF but I don't know how to put that HEREDOC into a varible to pass it to fdisk. This is what I have tried so far (no luck) #!/bin/bash ... (3 Replies)
Discussion started by: latenite
3 Replies

3. Shell Programming and Scripting

Problem in SFTP using heredoc

Hi, I'm having heredoc to get files from ftp server. #!/bin/bash /export/opt/SCssh/3.7.1_C0/bin/sftp csi@192.168.1.100 <<GET_FILES lcd /WEBSERVER_LINK/data_logs/ ls -l pub/csidata/GeneralAppFields_8_1_Feed.out pub/csidata/CtcCatalog_7_3_3_Feed.out get... (13 Replies)
Discussion started by: bheeshmaraja
13 Replies

4. Shell Programming and Scripting

heredoc error check

Hi, Is there any way to check the error in heredoc? Code: /export/opt/SCssh/3.7.1_C0/bin/sftp -B - csi@192.168.1.100 <<FTP lcd /WEBSERVER_LINK/data_logs/ ls pub/csidata/GeneralAppFields_8_1_Feed.out get pub/csidata/GeneralAppFields_8_1_Feed.out quit FTP Now I want to check... (1 Reply)
Discussion started by: bheeshmaraja
1 Replies

5. Shell Programming and Scripting

Variables in heredoc

I currently use this message to send e-mails in a script but I would also like to save the output of this code to a file as well while preserving the variables. What's the easiest way to accomplish this? #Sending mail notification when=`/bin/date` /usr/sbin/sendmail -t >2 <<-EOM... (2 Replies)
Discussion started by: woodson2
2 Replies

6. Shell Programming and Scripting

Calling sqlplus from Korn shell heredoc issue

Hi, I am facing an issue wherein some temporary files (here docs) are getting created in /tmp and are not getting deleted automatically. When i check the list of open files with below command i can see one file is getting appended continuously.(In this case /tmp/sfe7h.34p) The output is... (4 Replies)
Discussion started by: Navin_Ramdhami
4 Replies

7. Shell Programming and Scripting

Echo multi-line string via heredoc syntax

$ cat bashtest #!/usr/local/bin/bash echo <<<"EOF" line1 line2 line3 EOF $ ./bashtest ./bashtest: line 3: line1: command not found ./bashtest: line 4: line2: command not found ./bashtest: line 5: line3: command not found ./bashtest: line 6: EOF: command not found What am i doing... (4 Replies)
Discussion started by: urello
4 Replies

8. Shell Programming and Scripting

How To Concatenate Two Commands in script using heredoc?

Hello, I am trying to place two commands in heredoc below is the snippet if ;then actionOnTux="$actVerb" else actionOnTux="$actVerb" fi echo "Performing ACTION: $action on $tux@$srv .....\n" if ; then ... (5 Replies)
Discussion started by: kataria.anand
5 Replies

9. What is on Your Mind?

Not enough information...

I appreciate the fact that rules are for everyone and I screwed up by not putting a screen printout in code brackets... However, I was a bit dismayed when I received the following and tried to reply to say "Thank you" for sending me the reminder. I could not reply and had no idea what the... (4 Replies)
Discussion started by: RogerBaran
4 Replies
PPI::Token::HereDoc(3pm)				User Contributed Perl Documentation				  PPI::Token::HereDoc(3pm)

NAME
PPI::Token::HereDoc - Token class for the here-doc INHERITANCE
PPI::Token::HereDoc isa PPI::Token isa PPI::Element DESCRIPTION
Here-docs are incredibly handy when writing Perl, but incredibly tricky when parsing it, primarily because they don't follow the general flow of input. They jump ahead and nab lines directly off the input buffer. Whitespace and newlines may not matter in most Perl code, but they matter in here-docs. They are also tricky to store as an object. They look sort of like an operator and a string, but they don't act like it. And they have a second section that should be something like a separate token, but isn't because a strong can span from above the here-doc content to below it. So when parsing, this is what we do. Firstly, the PPI::Token::HereDoc object, does not represent the "<<" operator, or the "END_FLAG", or the content, or even the terminator. It represents all of them at once. The token itself has only the declaration part as its "content". # This is what the content of a HereDoc token is <<FOO # Or this <<"FOO" # Or even this << 'FOO' That is, the "operator", any whitespace separator, and the quoted or bare terminator. So when you call the "content" method on a HereDoc token, you get '<< "FOO"'. As for the content and the terminator, when treated purely in "content" terms they do not exist. The content is made available with the "heredoc" method, and the name of the terminator with the "terminator" method. To make things work in the way you expect, PPI has to play some games when doing line/column location calculation for tokens, and also during the content parsing and generation processes. Documents cannot simply by recreated by stitching together the token contents, and involve a somewhat more expensive procedure, but the extra expense should be relatively negligible unless you are doing huge quantities of them. Please note that due to the immature nature of PPI in general, we expect "HereDocs" to be a rich (bad) source of corner-case bugs for quite a while, but for the most part they should more or less DWYM. Comparison to other string types Although technically it can be considered a quote, for the time being "HereDocs" are being treated as a completely separate "Token" subclass, and will not be found in a search for PPI::Token::Quote or "PPI::Token::QuoteLike objects". This may change in the future, with it most likely to end up under QuoteLike. METHODS
Although it has the standard set of "Token" methods, "HereDoc" objects have a relatively large number of unique methods all of their own. heredoc The "heredoc" method is the authoritative method for accessing the contents of the "HereDoc" object. It returns the contents of the here-doc as a list of newline-terminated strings. If called in scalar context, it returns the number of lines in the here-doc, excluding the terminator line. terminator The "terminator" method returns the name of the terminating string for the here-doc. Returns the terminating string as an unescaped string (in the rare case the terminator has an escaped quote in it). TO DO
- Implement PPI::Token::Quote interface compatibility - Check CPAN for any use of the null here-doc or here-doc-in-s///e - Add support for the null here-doc - Add support for here-doc in s///e SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.10.1 2011-02-26 PPI::Token::HereDoc(3pm)
All times are GMT -4. The time now is 02:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy