“unexpected end of file” in bash script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5















I have this if in a bash script:



if [ $ACTION = deploy ]; then
$JAVA_HOME/bin/java $JVM_ARGS weblogic.WLST << EOJ
connect('XXX','XXX','t3://XXX:8001')
jndi();
ls();
disconnect();
exit ();
EOJ
else
echo "XXX"
fi


I think the error is in the EOJ.










share|improve this question
























  • By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

    – Emil
    May 16 '12 at 15:05











  • @BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

    – Gilles
    May 16 '12 at 22:54















5















I have this if in a bash script:



if [ $ACTION = deploy ]; then
$JAVA_HOME/bin/java $JVM_ARGS weblogic.WLST << EOJ
connect('XXX','XXX','t3://XXX:8001')
jndi();
ls();
disconnect();
exit ();
EOJ
else
echo "XXX"
fi


I think the error is in the EOJ.










share|improve this question
























  • By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

    – Emil
    May 16 '12 at 15:05











  • @BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

    – Gilles
    May 16 '12 at 22:54













5












5








5


1






I have this if in a bash script:



if [ $ACTION = deploy ]; then
$JAVA_HOME/bin/java $JVM_ARGS weblogic.WLST << EOJ
connect('XXX','XXX','t3://XXX:8001')
jndi();
ls();
disconnect();
exit ();
EOJ
else
echo "XXX"
fi


I think the error is in the EOJ.










share|improve this question
















I have this if in a bash script:



if [ $ACTION = deploy ]; then
$JAVA_HOME/bin/java $JVM_ARGS weblogic.WLST << EOJ
connect('XXX','XXX','t3://XXX:8001')
jndi();
ls();
disconnect();
exit ();
EOJ
else
echo "XXX"
fi


I think the error is in the EOJ.







bash shell-script here-document






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 20 at 19:38









Rui F Ribeiro

41.5k1483140




41.5k1483140










asked May 16 '12 at 7:07









ludieguludiegu

85231630




85231630












  • By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

    – Emil
    May 16 '12 at 15:05











  • @BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

    – Gilles
    May 16 '12 at 22:54

















  • By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

    – Emil
    May 16 '12 at 15:05











  • @BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

    – Gilles
    May 16 '12 at 22:54
















By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

– Emil
May 16 '12 at 15:05





By the way, all those semicolons are unnecessary. The only reason to use them is if you want multiple commands in the same line.

– Emil
May 16 '12 at 15:05













@BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

– Gilles
May 16 '12 at 22:54





@BryanGarza Really? Those semicolons aren't in the bash part, they're in the embedded Weblogic part.

– Gilles
May 16 '12 at 22:54










1 Answer
1






active

oldest

votes


















9














EOJ needs to be fully left-justified, ie. no leading white-space, and no trailing space either. Also, you could/should (depending on your needs) write the first one as <<'EOJ' .. the quotes disable some shell expansion which can otherwise occur.



From info bash




Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only delimiter (with no trailing
blanks) is seen. All of the lines read up to that point are then used
as the standard input for a command.




 The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or
pathname expansion is performed on word. If any characters in word are
quoted, the delimiter is the result of quote removal on word, and the
lines in the here-document are not expanded. If word is unquoted, all
lines of the here-document are subjected to parameter expansion, com‐
mand substitution, and arithmetic expansion. In the latter case, the
character sequence <newline> is ignored, and must be used to quote
the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are
stripped from input lines and the line containing delimiter. This
allows here-documents within shell scripts to be indented in a natural
fashion.





share|improve this answer

























  • That's it! I just needed to move the EOJ. Thanks!

    – ludiegu
    May 16 '12 at 7:24










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f38757%2funexpected-end-of-file-in-bash-script%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









9














EOJ needs to be fully left-justified, ie. no leading white-space, and no trailing space either. Also, you could/should (depending on your needs) write the first one as <<'EOJ' .. the quotes disable some shell expansion which can otherwise occur.



From info bash




Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only delimiter (with no trailing
blanks) is seen. All of the lines read up to that point are then used
as the standard input for a command.




 The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or
pathname expansion is performed on word. If any characters in word are
quoted, the delimiter is the result of quote removal on word, and the
lines in the here-document are not expanded. If word is unquoted, all
lines of the here-document are subjected to parameter expansion, com‐
mand substitution, and arithmetic expansion. In the latter case, the
character sequence <newline> is ignored, and must be used to quote
the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are
stripped from input lines and the line containing delimiter. This
allows here-documents within shell scripts to be indented in a natural
fashion.





share|improve this answer

























  • That's it! I just needed to move the EOJ. Thanks!

    – ludiegu
    May 16 '12 at 7:24















9














EOJ needs to be fully left-justified, ie. no leading white-space, and no trailing space either. Also, you could/should (depending on your needs) write the first one as <<'EOJ' .. the quotes disable some shell expansion which can otherwise occur.



From info bash




Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only delimiter (with no trailing
blanks) is seen. All of the lines read up to that point are then used
as the standard input for a command.




 The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or
pathname expansion is performed on word. If any characters in word are
quoted, the delimiter is the result of quote removal on word, and the
lines in the here-document are not expanded. If word is unquoted, all
lines of the here-document are subjected to parameter expansion, com‐
mand substitution, and arithmetic expansion. In the latter case, the
character sequence <newline> is ignored, and must be used to quote
the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are
stripped from input lines and the line containing delimiter. This
allows here-documents within shell scripts to be indented in a natural
fashion.





share|improve this answer

























  • That's it! I just needed to move the EOJ. Thanks!

    – ludiegu
    May 16 '12 at 7:24













9












9








9







EOJ needs to be fully left-justified, ie. no leading white-space, and no trailing space either. Also, you could/should (depending on your needs) write the first one as <<'EOJ' .. the quotes disable some shell expansion which can otherwise occur.



From info bash




Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only delimiter (with no trailing
blanks) is seen. All of the lines read up to that point are then used
as the standard input for a command.




 The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or
pathname expansion is performed on word. If any characters in word are
quoted, the delimiter is the result of quote removal on word, and the
lines in the here-document are not expanded. If word is unquoted, all
lines of the here-document are subjected to parameter expansion, com‐
mand substitution, and arithmetic expansion. In the latter case, the
character sequence <newline> is ignored, and must be used to quote
the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are
stripped from input lines and the line containing delimiter. This
allows here-documents within shell scripts to be indented in a natural
fashion.





share|improve this answer















EOJ needs to be fully left-justified, ie. no leading white-space, and no trailing space either. Also, you could/should (depending on your needs) write the first one as <<'EOJ' .. the quotes disable some shell expansion which can otherwise occur.



From info bash




Here Documents
This type of redirection instructs the shell to read input from the
current source until a line containing only delimiter (with no trailing
blanks) is seen. All of the lines read up to that point are then used
as the standard input for a command.




 The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or
pathname expansion is performed on word. If any characters in word are
quoted, the delimiter is the result of quote removal on word, and the
lines in the here-document are not expanded. If word is unquoted, all
lines of the here-document are subjected to parameter expansion, com‐
mand substitution, and arithmetic expansion. In the latter case, the
character sequence <newline> is ignored, and must be used to quote
the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are
stripped from input lines and the line containing delimiter. This
allows here-documents within shell scripts to be indented in a natural
fashion.






share|improve this answer














share|improve this answer



share|improve this answer








edited May 16 '12 at 9:15









camh

25.2k76353




25.2k76353










answered May 16 '12 at 7:12









Peter.OPeter.O

19.1k1891146




19.1k1891146












  • That's it! I just needed to move the EOJ. Thanks!

    – ludiegu
    May 16 '12 at 7:24

















  • That's it! I just needed to move the EOJ. Thanks!

    – ludiegu
    May 16 '12 at 7:24
















That's it! I just needed to move the EOJ. Thanks!

– ludiegu
May 16 '12 at 7:24





That's it! I just needed to move the EOJ. Thanks!

– ludiegu
May 16 '12 at 7:24

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f38757%2funexpected-end-of-file-in-bash-script%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)