How do we do programmatically set LD_LIBRARY_PATH for this scenario , mono-service ./AudioRecorder.exe where we are running on Ubuntu Linux 14.06 and AudioRecorder.exe is a C# .NET executable.

Karl Auer kauer at biplane.com.au
Sat May 14 01:28:10 UTC 2016


On Fri, 2016-05-13 at 16:37 -0700, Frank Chang wrote:
> How do we do programmatically set LD_LIBRARY_PATH for this scenario?

In the service stanza of your .service file, add a line like:

Environment=LD_LIBRARY_PATH=/what/ever/you/need

You can have multiple "Environment" lines, or if you have a whole heap
of them (and especially if you want to use the same environment for
multiple services) you can instead provide a file containing your
environment details and point to it with an "EnvironmentFile" directive
in the service stanza of your .service file:

EnvironmentFile=/path/to/file/containing/env

The lines in the environment file look like ordinary environment
variable sets:

LD_LIBRARY_PATH=/what/ever/you/need
THIS=blah
THAT=bloo

Another advantage of environment files is that you can generate them
programmatically.

This page has a good description of all of the above, including how to
generate an EnvironmentFile from within another service:

https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html

In Ubuntu, the sshd service uses an EnvironmentFile, see
/etc/systemd/system/sshd.service

Regards, K.


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4







More information about the ubuntu-users mailing list