Karim.Belabas on Fri, 2 Feb 2001 16:14:04 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Arguments


On Thu, 1 Feb 2001, Olivier Ramare wrote:

>   I want to run the program "Lchi.gp" (one of my own) in a cron job.
> My favorite instruction is thus essentially
> gp < Lchi.gp
> 
>   Then this script writes in a file. This particular script is
> a good example : it computes a quantity for a parameter
> varying in borneinf..bornesup. Since it is a fully parallelisable
> process, I have several machines working on it. And they
> thus write on different files. Till now, for each machine,
> for each range I change the script.
> 
> How can I send parameters with my script ?
> 
> There's a solution :
> cat mychoice.gp Lchi.gp | gp
> 
> I would like to know if I can send parameters directly.

You can use environment variables:

test.gp:
  a = Str("$A", 1);
  b = Str("$B", 1);
  print("args are: "a" "b)

(16:09)(*2) geo-karim % env A=hello B=world   gp -q < test.gp
args are: hello world

add.gp:
  a = eval(Str("$A", 1));
  b = eval(Str("$B", 1));  
  print("result is: " a + b)

(16:09)(*2) geo-karim % env A=1 B=2   gp -q < a.gp
result is: 3

      Karim.
--  
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://www.parigp-home.de/