Passing on script generated arguments to erl

Matthias Lang matthias@REDACTED
Mon Jul 5 15:07:25 CEST 2004


david wallin writes:

 > I've run into a problem when using erl with a bash script that 
 > generates the arguments I want to use in erlang.

Your problem is not an Erlang problem, it's the way BASH works. A
script does almost exactly the same thing:

   tmp >cat shellscript 
   #!
   echo "1:$1   2:$2"

   tmp >WORKLOAD="'foo 1' 'foo 2'"
   tmp >echo $WORKLOAD
   'foo 1' 'foo 2'
   tmp >./shellscript $WORKLOAD
   1:'foo   2:1'

Matthias

 > If I type something like this at the bash prompt everything works fine:
 > 
 > 	[dolly:~/southpaw] david% erl -- 'foo 1' 'foo 2'
 > 
 > 	Erlang (BEAM) emulator version 5.3 [source]
 > 
 > 	Eshell V5.3  (abort with ^G)
 > 	1> init:get_plain_arguments().
 > 	["foo 1","foo 2"]
 > 
 > 
 > If I try the script that automatically generates the arguments (just 
 > assume that the WORKLOAD var is generated by a script):
 > 
 > 	[dolly:~/southpaw] david% WORKLOAD="'foo 1' 'foo 2'"
 > 	[dolly:~/southpaw] david% echo $WORKLOAD
 > 	'foo 1' 'foo 2'
 > 	[dolly:~/southpaw] david% erl -- $WORKLOAD
 > 	Erlang (BEAM) emulator version 5.3 [source]
 > 
 > 	Eshell V5.3  (abort with ^G)
 > 	1> init:get_plain_arguments().
 > 	["'foo","1'","'foo","2'"]
 > 
 > 
 > Can anybody give me some advice on the matter, I'm currently leaning 
 > towards creating a temp file containing the arguments but the solution 
 > doesn't appeal to me.
 > 
 > cheers,
 > 
 > --david.



More information about the erlang-questions mailing list