Passing on script generated arguments to erl

david wallin david.wallin@REDACTED
Tue Jul 6 13:31:13 CEST 2004


Thanks,

I passed it along as a single string "foo 1::foo 2" separated by "::" 
and then used regexp:split/2. But your suggestion seems to be slightly 
more elegant, I will try it. Thanks.

cheers,

--david.

On 2004-07-05, at 15.23, Per Hedeland wrote:

> david wallin <david.wallin@REDACTED> wrote:
>>
>> blimey! you're right. thanks,
>
> Just in case you want a non-erlang solution to the non-erlang problem:
>
> eval erl -- "$WORKLOAD"
>
> --Per
>
>> On 2004-07-05, at 14.07, Matthias Lang wrote:
>>
>>> 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