From: Philipp F. <phi...@hh...> - 2006-12-08 13:44:55
|
Hello Is it possible to pass arguments to a Gnuplot script (in Linux on the command line), e.g. a file name for a data file. I would like to do the following kind of script: #! /usr/bin/gnuplot set title ARGV[1] plot ARGV[1].data using ($16 * 8):20 with linespoints notitle pause -1 This script should generate a plot with the title given as first command line argument, an with the graph constructed from the first command line argument added with the suffix .data. Best regards Philipp ________________________________________________________________________ Dipl.-Ing. Philipp Fechteler Department Image Processing Fraunhofer Institute for Telecommunications Heinrich-Hertz-Institut (HHI) Einsteinufer 37 10587 Berlin, Germany Phone +49 30 31002 616 Fax +49 30 31002 200 Email phi...@hh... WWW http://iphome.hhi.de/fechteler ________________________________________________________________________ |
From: <HBB...@t-...> - 2006-12-08 21:32:30
|
Philipp Fechteler wrote: > Is it possible to pass arguments to a Gnuplot script (in Linux on the > command line), e.g. a file name for a data file. I would like to do the > following kind of script: > > #! /usr/bin/gnuplot > set title ARGV[1] > plot ARGV[1].data using ($16 * 8):20 with linespoints notitle > pause -1 The easiest would be not to make them direct /usr/bin/gnuplot scripts, but rather something like this: #! /bin/sh name=$1 /usr/bin/gnuplot <<\EOF set title "$name" plot "$name.data" using (\$16 * 8):20 with linespoints notitle pause -1 EOF Alternatively, you can put the arguments into environment variables and use `echo $VARIABLE` in your gnuplot script to access them. |
From: SB <ste...@gm...> - 2006-12-11 11:01:06
|
Hello Philipp, I had a similar problem and used a slightly different way than Bernard suggested. It is not as elegant but there are advanced possibilities. I wrote a script that first creates a gnuplot-script-file (plotfile.gnu) and then calles gnuplot to open it. The gnuplot-script-file will look exactly like the one you asked for, with one extra line (save "diagramm.gnu") at the end. The script for your problem could look similar to the following one: #!/bin/sh #Step 1: create file echo set title $1 > plotfile.gnu echo plot $1.data using (\$16 * 8):20 with linespoints notitle >>plotfile.gnu echo pause -1 >>plotfile.gnu echo save \"diagramm.gnu\" #Step 2: call gnuplot gnuplot plotfile.gnu When you see the plot, gnuplot is in interactive mode and you can therefore zoom in and out, turn on/off logscale and so on. If you liked the plot, rename the file "diagramm,gnu" and you have it saved with the last settings for zoom and so on. By the way, you can also teach KDE/Gnome/... to open your .data-files by click with a script like this. You need to modify the script that it accepts the complete filename. Then set the file associations of KDE/Gnome/... to open .data-files with this script. Then you just click on your .data file in the file-browser and have it displayed directly. I hope, this can be useful for you, Schöne Grüße, Stephan Am Freitag, den 08.12.2006, 14:45 +0100 schrieb Philipp Fechteler: > Hello > > Is it possible to pass arguments to a Gnuplot script (in Linux on the > command line), e.g. a file name for a data file. I would like to do the > following kind of script: > > #! /usr/bin/gnuplot > set title ARGV[1] > plot ARGV[1].data using ($16 * 8):20 with linespoints notitle > pause -1 > > This script should generate a plot with the title given as first command > line argument, an with the graph constructed from the first command line > argument added with the suffix .data. > > Best regards > Philipp > > ________________________________________________________________________ > Dipl.-Ing. Philipp Fechteler > Department Image Processing > Fraunhofer Institute for Telecommunications > Heinrich-Hertz-Institut (HHI) > Einsteinufer 37 > 10587 Berlin, Germany > Phone +49 30 31002 616 > Fax +49 30 31002 200 > Email phi...@hh... > WWW http://iphome.hhi.de/fechteler > ________________________________________________________________________ > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Gnuplot-info mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
From: LukasP <LP...@po...> - 2009-12-20 08:42:40
|
Hello all, I have the same problem - how to access parameters passed on the system command line. I am a Windows user, so solutions described above are unreachable for me. Let's have system command: wgnuplot.exe tab2png.gp test.tab Inside the tab2png.gp, I need to access test.tab passed on the command line. How to do it? Do you think it would be possible or useful to implement built-in variables (e.g. ARG1, ... ARG9) which would represent the command line arguments for [w]gnuplot? Or to create a built-in function e.g. getenv(varname) which would get the environment variable? So it would be possible to write to the command line: C:\> wgnuplot.exe tab2png.gp test.tab or: C:\> set FILE=test.tab C:\> wgnuplot.exe tab2png.gp And the tab2png would look e.g.: plot $ARGV1 using 1:2 with lines or: set FILE getenv("FILE") plot FILE using 1:2 with lines Thank you in advance Lukas -- View this message in context: http://old.nabble.com/command-line-arguments-to-gnuplot-scripts-tp7757834p26861786.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: seb_kramm <seb...@ya...> - 2009-12-22 11:33:16
|
LukasP a écrit : > Let's have system command: > wgnuplot.exe tab2png.gp test.tab I'm not sure what you want exactly, I guess it is a generated line from somewhere else. If you can remove the .exe in the calling line, then just create a simple wgnuplot.bat, that is given priority over the .exe by the OS It will just contain these lines: dowhatyouwant.exe %1 %2 wgnuplot.exe %1 %2 with "dowhatyouwant.exe" ( or .bat) being the app that will fetch the arguments Of course, beware of spaces (or use quotes) |
From: Hans-Bernhard B. <HBB...@t-...> - 2009-12-20 17:45:53
|
LukasP wrote: > I have the same problem - The same as --- which one? > how to access parameters passed on the system command line. You don't, because you can't pass them. gnuplot treats all command line arguments as file names or options, but not as parameters. > I am a Windows user, so solutions described above are unreachable for me. Again: what "above" are you referring to? > Do you think it would be possible or useful to implement built-in variables > (e.g. ARG1, ... ARG9) which would represent the command line arguments for > [w]gnuplot? No. Because all such arguments already are script filenames. A single argument can't be two different things at once. > Or to create a built-in function e.g. getenv(varname) which would get the > environment variable? Not need to. Piping the 'echo' command already does that. _If_ you use the wgnuplot_pipes.exe or the (soon to become available) gnuplot.exe console version, that is. > set FILE getenv("FILE") set FILE=system("echo %FILE%") |
From: LukasP <LP...@po...> - 2009-12-21 10:06:36
|
... OK, thank you for the explanation. I didn't realize that all gnuplot parameters are treated as file names. Sorry. Hans-Bernhard Bröker-2 wrote: > > You don't, because you can't pass them. gnuplot treats all command line > arguments as file names or options, but not as parameters. > > set FILE=system("echo %FILE%") > I tried to get environment variable as suggested, but I was not successful, see the output: Terminal type set to 'windows' gnuplot> FILE=system("echo %HOME%") warning: system evaluation not supported by MS-Windows 32 bit So how to get it? Note that the "HOME" variable was set to "C:\Lukas" via system command: set HOME=C:\Lukas (Hope there won't be any problems using "\" in file names, although the "/" is used at Linux systems and "\" is often the escape-sequence prefix.) Thank you in advance. Lukas NB: G N U P L O T Version 4.2 patchlevel 6 last modified Sep 2009 System: MS-Windows 32 bit Copyright (C) 1986 - 1993, 1998, 2004, 2007 - 2009 Thomas Williams, Colin Kelley and many others -- View this message in context: http://old.nabble.com/command-line-arguments-to-gnuplot-scripts-tp7757834p26871956.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: Tatsuro M. <tma...@ya...> - 2009-12-21 10:58:44
|
Hans Wrote ********** If_ you use the wgnuplot_pipes.exe or the (soon to become available) gnuplot.exe console version, that is. ********** You should use wgnuplot_pipes.exe but not wgnuplot.exe if you would like to use gnuplot 4.2.6 as Hans wrote. You can also use gnuplot.exe in gnuplot 4.4rc1 or 4.5 (cvs). windows version gnuplot 4.4rc1 is available at http://sourceforge.net/projects/gnuplot/files/ I am distributing gnuplot 4.4rc1 or 4.5 (cvs) at http://www.tatsuromatsuoka.com/gnuplot/Eng/winbin/ Regards Tatsuro --- LukasP <LP...@po...> wrote: > > ... OK, thank you for the explanation. > > I didn't realize that all gnuplot parameters are treated as file names. > Sorry. > > > Hans-Bernhard Br将モker-2 wrote: > > > > You don't, because you can't pass them. gnuplot treats all command line > > arguments as file names or options, but not as parameters. > > > > set FILE=system("echo %FILE%") > > > > I tried to get environment variable as suggested, but I was not successful, > see the output: > > Terminal type set to 'windows' > gnuplot> FILE=system("echo %HOME%") > warning: system evaluation not supported by MS-Windows 32 bit > > So how to get it? Note that the "HOME" variable was set to "C:\Lukas" via > system command: > > set HOME=C:\Lukas > > (Hope there won't be any problems using "\" in file names, although the "/" > is used at Linux systems and "\" is often the escape-sequence prefix.) > > Thank you in advance. > > Lukas > > NB: > > G N U P L O T > Version 4.2 patchlevel 6 > last modified Sep 2009 > System: MS-Windows 32 bit > > Copyright (C) 1986 - 1993, 1998, 2004, 2007 - 2009 > Thomas Williams, Colin Kelley and many others > > -- > View this message in context: > http://old.nabble.com/command-line-arguments-to-gnuplot-scripts-tp7757834p26871956.html > Sent from the Gnuplot - User mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > -------------------------------------- Get Disney character's mail address on Yahoo! Mail http://pr.mail.yahoo.co.jp/disney/ |
From: Ismail A. <ism...@go...> - 2010-05-29 23:32:11
|
Hello The best way to do is to use environment variables in shell and access them in Gnuplot script Example: ------------------------------------------------------------- In the shell: export name=plot_data_file ------------------------------------------------------------- In Gnuplot script: #! /usr/bin/gnuplot name=system("echo $plot_data_file") set title name plot name.".data" using ($16 * 8):20 with linespoints notitle pause -1 ------------------------------------------------------------- Best regards, Ismail Amin Philipp Fechteler wrote: > > Hello > > Is it possible to pass arguments to a Gnuplot script (in Linux on the > command line), e.g. a file name for a data file. I would like to do the > following kind of script: > > #! /usr/bin/gnuplot > set title ARGV[1] > plot ARGV[1].data using ($16 * 8):20 with linespoints notitle > pause -1 > > This script should generate a plot with the title given as first command > line argument, an with the graph constructed from the first command line > argument added with the suffix .data. > > Best regards > Philipp > > ________________________________________________________________________ > Dipl.-Ing. Philipp Fechteler > Department Image Processing > Fraunhofer Institute for Telecommunications > Heinrich-Hertz-Institut (HHI) > Einsteinufer 37 > 10587 Berlin, Germany > Phone +49 30 31002 616 > Fax +49 30 31002 200 > Email phi...@hh... > WWW http://iphome.hhi.de/fechteler > ________________________________________________________________________ > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Gnuplot-info mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > -- View this message in context: http://old.nabble.com/command-line-arguments-to-gnuplot-scripts-tp7757834p28719227.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |