[erlang-questions] shell question - import commands from external file

John Hughes john.hughes@REDACTED
Mon Sep 21 11:29:48 CEST 2009

>> I have a newbie question.  In the shell, is there a way to import
>> *shell* commands from
>> an external file?  I'm often experimenting in the shell, e.g., writing
>> a 5 or 8 line fun,
>> trying out this or that function call, etc.
>> Since there are often mistakes, I need to rewrite the fun a few times.
>>  Instead of
>> having to retype (or look up in history) the several lines, I'd like
>> to write the fun
>> in a temporary file (e.g., ./tmp.erl) and then just load it into the
>> shell as if i'd
>> typed it in (e.g., in the postgresql shell I would do, "\i [filename").
> I don't think there is any mechanism that would allow you to evaluate text
> in a file that contains shell commands like f(), c(), etc.
> But maybe file:consult/1, file:eval/1 or file:eval/2 might be close enough
> to what you're looking for?
> Robby


I generally prefer to put even temporary definitions in a file and compile 
them though, not least so I don't have to use the full-blown module:function 
syntax everywhere.


More information about the erlang-questions mailing list