[erlang-questions] erlsrv.html info

Patrik Nyblom pan@REDACTED
Tue Dec 18 11:41:04 CET 2012


On 12/14/2012 11:16 PM, Wes James wrote:
> Looking at this documentation to see where .erlang.cookie might be 
> saved for a service (installed with erlsrv) so I don't have to do 
> -cookie on the command line, the docs at:
>
> http://www.erlang.org/doc/man/erlsrv.html
>
> say that the default working directory is:
>
> %SystemDrive%%SystemPath%
>
> There is a %SystemDrive% in win 7 (type set in the cmd.exe window) but 
> there is no %SystemPath%.  There is a %windir% and %SystemRoot% which 
> are c:\windows on my system.  Anyway, I don't see .erlang.cookie in 
> c:\windows after using erlsrv and starting the service. Where is 
> .erlang.cookie for erlsrv services?
Yes, the %SystemPath% is not present on modern Windows. The local 
administrator (which is the user that runs the service) has c:\Windows 
as home directory by default, but the service runs with 
c:\Windows\system32 as default directory.

One way to make sure is to simply start a service with a debug console 
and add -emu_args as a parameter, click "Show message" or whatever your 
locale has to select in the dialogue that pops up (or does not pop up 
but starts to blink in the task bar) when you start such a service and 
then do a pwd(). In the Erlang shell that you will see the -home parameter.

Example (replace mentally any paths with the appropriate ones for your 
system):

C:\blabla> cd "c:\Program Files\erl5.9.3.1\erts-5.9.3.1\bin"
C:\Program Files\erl5.9.3.1\erts-5.9.3.1\bin>erlsrv add testservice 
-debug console -arg -emu_args
C:\Program Files\erl5.9.3.1\erts-5.9.3.1\bin>erlsrv start testservice

...click on the "show me the message" button in the service control 
manager dialogue, which will take you to a blank screen with only the 
Erlang shell of the service and a dialogue that can take you back to the 
desktop. In that shell, you will see the full command line to the VM 
including the '-home' parameter:
---------------
Executing: C:\blablabla...\beam.smp.dll C:\blablabla...\beam.smp.dll -- 
-root C:\blablabla -progname erl -- -home c:\Windows etc etc etc
1> pwd().
c:/Windows/system32
2>
---------------
...click on the get me back button in the dialogue that hangs beside the 
shell. The directory after the -home in the "slogan" at the top of the 
shell should be the home directory. The result from pwd() is the default 
"current directory" of the service.

So the .erlang.cookie should reside in what -home says, which 
corresponds to %SystemDrive%%SystemRoot%, while files created in current 
directory will go into whatever pwd() shows.

Now stop and remove the service:
C:\Program Files\erl5.9.3.1\erts-5.9.3.1\bin>erlsrv stop testservice
...will take some time because of the peculiarities of a debug console....
C:\Program Files\erl5.9.3.1\erts-5.9.3.1\bin>erlsrv remove service

Hope that helps!

Cheers,
/Patrik

>
> Thanks,
>
> wes
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121218/d0d12ffb/attachment.htm>


More information about the erlang-questions mailing list