gnuplot, here-documents, and command line arguments

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











up vote
0
down vote

favorite












Can I use a here document to pass a gnuplot script to gnuplot and also have commandline line arguments passed to gnuplot?



In my bash file, I would normally write:



#!/bin/bash
#set up code in here...
gnuplot -c script.gp $first $second


But I want to have everything in one bash file, so I've done



#!/bin/bash
#set up code in here...
gnuplot -c <<- EOF
do for [j=0:ARG1]
do for [i=4:ARG2]
plot '$data' index j using 2:i with lp


EOF $first $second


but I get the infamous warning: here-document at line 87 delimited by end-of-file (wantedEOF')`` error. $data, $first, and $second are defined earlier in the bash script.



If I put the command line arguments on the next line, to leave the EOF alone, I get command not found errors associated with the value of $first.



My here document is indented only with tabs. There is no trailing whitespace.










share|improve this question

























    up vote
    0
    down vote

    favorite












    Can I use a here document to pass a gnuplot script to gnuplot and also have commandline line arguments passed to gnuplot?



    In my bash file, I would normally write:



    #!/bin/bash
    #set up code in here...
    gnuplot -c script.gp $first $second


    But I want to have everything in one bash file, so I've done



    #!/bin/bash
    #set up code in here...
    gnuplot -c <<- EOF
    do for [j=0:ARG1]
    do for [i=4:ARG2]
    plot '$data' index j using 2:i with lp


    EOF $first $second


    but I get the infamous warning: here-document at line 87 delimited by end-of-file (wantedEOF')`` error. $data, $first, and $second are defined earlier in the bash script.



    If I put the command line arguments on the next line, to leave the EOF alone, I get command not found errors associated with the value of $first.



    My here document is indented only with tabs. There is no trailing whitespace.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Can I use a here document to pass a gnuplot script to gnuplot and also have commandline line arguments passed to gnuplot?



      In my bash file, I would normally write:



      #!/bin/bash
      #set up code in here...
      gnuplot -c script.gp $first $second


      But I want to have everything in one bash file, so I've done



      #!/bin/bash
      #set up code in here...
      gnuplot -c <<- EOF
      do for [j=0:ARG1]
      do for [i=4:ARG2]
      plot '$data' index j using 2:i with lp


      EOF $first $second


      but I get the infamous warning: here-document at line 87 delimited by end-of-file (wantedEOF')`` error. $data, $first, and $second are defined earlier in the bash script.



      If I put the command line arguments on the next line, to leave the EOF alone, I get command not found errors associated with the value of $first.



      My here document is indented only with tabs. There is no trailing whitespace.










      share|improve this question













      Can I use a here document to pass a gnuplot script to gnuplot and also have commandline line arguments passed to gnuplot?



      In my bash file, I would normally write:



      #!/bin/bash
      #set up code in here...
      gnuplot -c script.gp $first $second


      But I want to have everything in one bash file, so I've done



      #!/bin/bash
      #set up code in here...
      gnuplot -c <<- EOF
      do for [j=0:ARG1]
      do for [i=4:ARG2]
      plot '$data' index j using 2:i with lp


      EOF $first $second


      but I get the infamous warning: here-document at line 87 delimited by end-of-file (wantedEOF')`` error. $data, $first, and $second are defined earlier in the bash script.



      If I put the command line arguments on the next line, to leave the EOF alone, I get command not found errors associated with the value of $first.



      My here document is indented only with tabs. There is no trailing whitespace.







      bash here-document gnuplot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 8 at 6:29









      masher

      1084




      1084




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          You could try something like:



          gnuplot -c /dev/stdin "$first" "$second" <<-EOF
          do for [j=0:ARG1]
          do for [i=4:ARG2]
          plot '$data' index j using 2:i with lp


          EOF


          Gnuplot complains



          line 4: No previous filename


          but then I get the same error when using a script file, so it's probably something to do with the code being incomplete.






          share|improve this answer



























            up vote
            0
            down vote













            This is one solution: get rid of the arguments, and do the replacement manually.



            #!/bin/bash
            #set up code in here...
            gnuplot <<- EOF
            do for [j=0:$first]
            do for [i=4:$second]
            plot '$data' index j using 2:i with lp


            EOF





            share|improve this answer




















              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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              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%2f461212%2fgnuplot-here-documents-and-command-line-arguments%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote













              You could try something like:



              gnuplot -c /dev/stdin "$first" "$second" <<-EOF
              do for [j=0:ARG1]
              do for [i=4:ARG2]
              plot '$data' index j using 2:i with lp


              EOF


              Gnuplot complains



              line 4: No previous filename


              but then I get the same error when using a script file, so it's probably something to do with the code being incomplete.






              share|improve this answer
























                up vote
                1
                down vote













                You could try something like:



                gnuplot -c /dev/stdin "$first" "$second" <<-EOF
                do for [j=0:ARG1]
                do for [i=4:ARG2]
                plot '$data' index j using 2:i with lp


                EOF


                Gnuplot complains



                line 4: No previous filename


                but then I get the same error when using a script file, so it's probably something to do with the code being incomplete.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  You could try something like:



                  gnuplot -c /dev/stdin "$first" "$second" <<-EOF
                  do for [j=0:ARG1]
                  do for [i=4:ARG2]
                  plot '$data' index j using 2:i with lp


                  EOF


                  Gnuplot complains



                  line 4: No previous filename


                  but then I get the same error when using a script file, so it's probably something to do with the code being incomplete.






                  share|improve this answer












                  You could try something like:



                  gnuplot -c /dev/stdin "$first" "$second" <<-EOF
                  do for [j=0:ARG1]
                  do for [i=4:ARG2]
                  plot '$data' index j using 2:i with lp


                  EOF


                  Gnuplot complains



                  line 4: No previous filename


                  but then I get the same error when using a script file, so it's probably something to do with the code being incomplete.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 8 at 7:21









                  muru

                  33.6k577144




                  33.6k577144






















                      up vote
                      0
                      down vote













                      This is one solution: get rid of the arguments, and do the replacement manually.



                      #!/bin/bash
                      #set up code in here...
                      gnuplot <<- EOF
                      do for [j=0:$first]
                      do for [i=4:$second]
                      plot '$data' index j using 2:i with lp


                      EOF





                      share|improve this answer
























                        up vote
                        0
                        down vote













                        This is one solution: get rid of the arguments, and do the replacement manually.



                        #!/bin/bash
                        #set up code in here...
                        gnuplot <<- EOF
                        do for [j=0:$first]
                        do for [i=4:$second]
                        plot '$data' index j using 2:i with lp


                        EOF





                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          This is one solution: get rid of the arguments, and do the replacement manually.



                          #!/bin/bash
                          #set up code in here...
                          gnuplot <<- EOF
                          do for [j=0:$first]
                          do for [i=4:$second]
                          plot '$data' index j using 2:i with lp


                          EOF





                          share|improve this answer












                          This is one solution: get rid of the arguments, and do the replacement manually.



                          #!/bin/bash
                          #set up code in here...
                          gnuplot <<- EOF
                          do for [j=0:$first]
                          do for [i=4:$second]
                          plot '$data' index j using 2:i with lp


                          EOF






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 8 at 6:55









                          masher

                          1084




                          1084



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461212%2fgnuplot-here-documents-and-command-line-arguments%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Bahrain

                              Postfix configuration issue with fips on centos 7; mailgun relay