Menu

#480 Access to positional command-line arguments (argv)

None
closed-out-of-date
nobody
None
5
2018-10-09
2018-09-11
Mikhail T.
No

Most command-line tools operating on files take filenames on command-line. Gnuplot scripts usually hard-code filenames in them -- because passing variables is rather unwieldy. Note the need for double-quoting, etc gnuplot -e 'inputname="foo.txt"' -e 'outputname="foo.png"' script.plg.

Perhaps, a variable -- or a function -- can be introduced to access the command-line arguments from inside? So that, instead of the above, one could say simply: gnuplot script.plg foo.txt foo.png? Easier to type, easier to place into Makefiles, and otherwise better...

Inside the plot-script, it would then be something like:

set output argv[2]
plot argv[1] 1:3

Discussion

  • Ethan Merritt

    Ethan Merritt - 2018-09-11

    Have you looked at the -c command line flag?

    For your example:
    gnuplot -c script.plg foo.txt foo.png

     
  • Ethan Merritt

    Ethan Merritt - 2018-10-09
    • status: open --> closed-out-of-date
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB