Skip to main content

Run any program with environment read from file

Project description

envirun

Load environment from file and run any program with this loaded environment.

This is useful if you want to easily run program with different environment, or troubleshoot systemd services which reads environment from /etc/default/ files.

Installation

pip3 install envirun

Example Usage

/tmp/x.sh:

#!/bin/sh

echo X: $X
echo $*

/tmp/x1.env: X=1 /tmp/x2.env: X=2

$ envirun.py /tmp/x1.env /tmp/x.sh some args
X: 1
some args

$ envirun.py /tmp/x2.env /tmp/x.sh some other args --foo --bar
X: 2
some other args --foo --bar

Source code

See environ.py, it's very simple. Main code is just three lines:

load_dotenv(dotenv_path=sys.argv[1], override=True)
rc = subprocess.run(sys.argv[2:])
sys.exit(rc.returncode)

More details

Environment files are loaded using dotenv load_dotenv(), overriding existing env variables. Environment lines may start with export. See dotenv documentation if you want more details.

See also similar project: envrun

How to achieve same result without envirun in bash (with few more commands):

$ set -a
$ . /tmp/x1.env  # Load environment from /tmp/x1.env file
$ set +a
$ /tmp/x.sh some args
X: 1
some args

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

envirun-0.0.1-py3-none-any.whl (2.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page