LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-02-2016, 12:54 PM   #1
4dummies
LQ Newbie
 
Registered: May 2009
Location: Central coast of California.
Distribution: Xubuntu
Posts: 18

Rep: Reputation: 1
Using "here documents" in batch jobs not working


I'm thinking about using batch(1) for some simple but numerous things I want to do on my hobby project. A few hundred thousand of them before I'm done. The most obvious way to do this for me involves putting data in a "here document". This is not working for me, either in at(1) jobs or batch(1) jobs.

Example:

kevin:~$ at noon
warning: commands will be executed using /bin/sh
at> echo <<EOF >noon.output
at> foo
at> bar
at> EOF
at> <EOT
job 9 at Sat Jan 2 12:00:00 2016

Using "at -c 9" I can see that the job consists of a bunch of environment setup scripting followed by just what I would expect:

cd /home/kevin || {
echo 'Execution directory inaccessible' >&2
exit 1
}
echo <<EOF >noon.output
foo
bar
EOF

But when the job executes, what I get in noon.output is a single blank line (a file containing only a newline).

Now I know how to work around this by creating temporary files containing the data, but that's a complication I'd rather avoid. Besides, I just want to know why this isn't working. It's not a
problem with /bin/sh that I know of, since that shell does here documents just fine.

Any ideas? Is there a better place to ask this?

Last edited by 4dummies; 01-02-2016 at 01:04 PM.
 
Old 01-02-2016, 02:06 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,388

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
You should use cat instead of echo, because echo doesn't read stdin (here-documents send their data to stdin).
 
1 members found this post helpful.
  


Reply

Tags
batch


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch user creating with the "newusers" command question mainuser Linux - Newbie 1 07-26-2011 08:35 PM
My "expect" script is not working... Won't "send" commands... edomingox Programming 4 04-02-2009 04:25 PM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 08:11 PM
Shell and batch operations on hidden files but not on ".." & "." danielsbrewer Linux - Software 5 09-12-2007 09:06 AM
how can I view and edit "Documents to Go" documents in Linux? izquierdista Linux - Software 7 08-30-2007 08:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration