|
From: tmacchant <tma...@ya...> - 2015-06-15 23:13:28
|
> okay if i want to pass a parameter ,i have the bash script and i want to call my gnuplot file and pass > > this parameter (which is a number)to it . now in the bash script i used > this command gnuplot /home/yas/file.gnuplot $1 > and in the gnuplot file i need to be able to take this $1 ..how to do > that? > i tried arg but it did not work! I did not say the below works gnuplot /home/yas/file.gnuplot $1 I have wrote some working examples. Did not you look those? As far as I know, there are two ways to pass the parameter to the script. The below examples were already written in separately, but I summarize in one for the convenience. **************************************************** 1. Scripts are prepared to use parameters and initial values of them are determined outside of script. #test.gp set term pngcairo set out 'paratest.png plot a*x+b set out #end of test.gp echo "a=2;b=3;load 'test.gp'" | gnuplotcvs or gnuplot -e "a=2;b=3;load 'test.gp'" 2. Prepare scripts using argument variable ($0, $1,... (ver. <= 4) or ARG1, ARG2, (ver.5)) and argument passed by command line **************************************************************************** Note that command line options are changed at ver. 5. Version 4 $ gnuplot --help Usage: gnuplot [OPTION]... [FILE] for X11 options see 'help X11->command-line-options' -V, --version -h, --help -p --persist -d --default-settings -e "command1; command2; ..." Version 5 $ gnuplot --help Usage: gnuplot [OPTION] ... [FILE] for X11 options see 'help X11->command-line-options' -V, --version -h, --help -p --persist -d --default-settings -c scriptfile ARG1 ARG2 ... -e "command1; command2; ..." The option to use call mechanism is added on ver. 5 -c scriptfile ARG1 ARG2 ... **************************************************************************** I show a example for ver.5 #calltest.gp a=ARG1; b=ARG2 set term pngcairo set out 'paratest.png plot a*x+b set out #end of calltest.gp gnuplotcvs -e "call 'calltest.gp' 2 3" # works on all version or gnuplotcvs -c calltest.gp 2 3 # works only on ver. 5 or later For ver.4 or before, ARG1 and ARG2 should be replaced by $0 and $1. Note for call script for ver.4 or before, NOTE: there is a clash in syntax with the datafile `using` callback operator. Use `$$n` or `column(n)` to access column n from a datafile inside a `call`ed datafile plot. Tatsuro -- View this message in context: http://gnuplot.10905.n7.nabble.com/passing-an-argument-to-gnuplot-script-tp94p19532.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |