[erlang-questions] problem running escript upon linux startup

Kris Prieb kris_prieb@REDACTED
Tue Mar 31 21:50:09 CEST 2009

Hello list,

The following escript fails when run upon linux (ubuntu) startup:

%% -*- erlang -*-
%%! -env HOME /root
main(_) -> file:write_file("/root/simple_start_output", "bunch of text").

The program should create a file called "simple_start_output," under
the root directory, but no such file appears when I log into the
A look at /var/logsyslog/ reveals a "erlexec: HOME must be set"
message resulting from the execution of the script.  The strange thing
is that the script works fine when I run it after logging in.

I've tried variations of the script such as:

1. using "/root" instead of /root when setting the HOME environment
variable in the 3rd line of the script
2. excluding the 3rd line of the script entirely
3. using "/usr/bin/env escript" instead of calling "/usr/bin/escript"

All scripts result in the same error,  "erlexec: HOME must be set,"
when run at startup.  However, they all work when run after logging
in.  Does anyone have an idea of how to get an escript to run at
startup??  Any thoughts would be greatly appreciated.  Thanks!

Kris Prieb

(I should also mention that I am actually running the script at the
launch of an Amazon EC2 virtual server, not on a machine that is
physically in front of me.  Not sure if that matters one way or

More information about the erlang-questions mailing list