I've created a shell script, which accepts information using an input from the console. Part of the script will write a file containing this information.
My code looks like (for the write)
function make_file
{
cat <<- _EOF_
The contents of my file are here
_EOF_
}
make_file >> /home/cpickering/$file.conf
However, when I run the script, the other sections work, just not the writing of the file.
The contents of $file are collected from my users input..
I'm with kshji the script most likely has an unmatched quoted pair. The easy way to find this is to download an editor that understands shell script. I use 'jedit' on my pc and copy any scripts I'm having issue with and open them in jedit. The editor will change all the text to PINK between quotes, so if your missing one it is obvious where you need to insert one to correct the issue.
if I might add, both methyl and jlliagre are right-ish on the matter of the syntax...but kshji is most right in suggesting a bum char is gumming up the works...
The "<<- _EOF_" is very much usable (as well as not necessary...), so long as the shell supports it and the whitespace is in fact a space (hex:20). A tab char will not do, and actually causes the function to hang altogether, so an od -c would be most helpful in sorting out the root cause of the failure. Otherwise, manually re-create what you want to happen and then copy/paste it from whatever history file you're logging to...
My .02...
---------- Post updated at 20:39 ---------- Previous update was at 20:38 ----------
actually, it was jlliagre who'd suggested the octal dump...my bad!
---------- Post updated at 20:54 ---------- Previous update was at 20:39 ----------
can't leave well-enough alone...
$ tail -16 file_test.txt
cat <<- _EOF_
blah...[space]
_EOF_
cat <<- _EOF_
blah...[tab]-less
_EOF_
cat <<- _EOF_
blah...[tab]-more
_EOF_
cat <<- _EOF_
blah...[space]-tab
_EOF_
$ tail -16 file_test.txt |od -c
0000000 \r \n c a t < < - _ E O F _ \r
0000020 \n b l a h . . . [ s p a c e ] \r
0000040 \n _ E O F _ \r \n \r \n c a t < <
0000060 - \t _ E O F _ \r \n b l a h . . .
0000100 [ t a b ] - l e s s \r \n _ E O F
0000120 _ \r \n \r \n c a t < < - \t _ E O
0000140 F _ \r \n b l a h . . . [ t a b ]
0000160 - m o r e \r \n \t _ E O F _ \r \n \r
0000200 \n c a t < < - _ E O F _ \r \n
0000220 b l a h . . . [ s p a c e ] - t
0000240 a b \r \n \t _ E O F _ \r \n
0000254