Env

Env

env is a shell command for Unix and Unix-like operating systems. It is used to either print a list of environment variables or run another utility in an altered environment without having to modify the currently existing environment. Using env, variables may be added or removed, and the values of existing variables may be changed.

In practice, env has another common use. It is often used by shell scripts to launch the correct interpreter. In this usage, the environment is typically not changed.

Examples

To clear the environment for a new shell:

env - /bin/sh

To launch the X Window application xcalc and have it appear on a different display:

env DISPLAY=foo.bar:1.0 xcalc

Here is the code of a very simple Python script:


#!/usr/bin/env pythonprint "Hello World."

In this example, /usr/bin/env is the full path of the env command. The environment is not altered.

Note that it is possible to specify the interpreter without using env, by giving the full path of the python interpreter. A problem with that approach is that on different computer systems, the exact path may be different. By instead using env as in the example, the interpreter is searched for and located at the time the script is run. This makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches for a match in every directory on the executable search path.

External links

* [http://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html env] -- manual page from GNU coreutils.
*man|1|env|Linux| run a program in a modified environment


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • env — UNIX‐утилита, исполняющая команду с изменением окружения. Входит, например, в gettext от GNU. Содержание 1 Использование 2 Параметры запуска 3 Примеры …   Википедия

  • Env — (von engl. environment = Umgebung) ist ein Unix Befehl, der entweder eine Liste der Umgebungsvariablen anzeigt oder ein anderes Programm in einer anderen Umgebung ausführt, ohne die Variablen der aktuellen Umgebung zu ändern. Mittels env können… …   Deutsch Wikipedia

  • env — (von engl. environment = Umgebung) ist ein Unix Befehl, der entweder eine Liste der Umgebungsvariablen anzeigt oder ein anderes Programm in einer anderen Umgebung ausführt, ohne die Variablen der aktuellen Umgebung zu ändern. Mittels env können… …   Deutsch Wikipedia

  • Env — UNIX‐утилита, исполняющая команду с изменением окружения. Входит, например, в gettext от GNU. Использование env [ПАРАМЕТР]… [ ] [ПЕРЕМЕННАЯ=ЗНАЧЕНИЕ]… [КОМАНДА [АРГУМЕНТЫ]…] Параметры запуска i, ignore environment исполняет команду с пустым… …   Википедия

  • env — abbrev. envelope * * * …   Universalium

  • env — abbrev. envelope …   English World dictionary

  • ENV — Die Abkürzung ENV oder env steht für: Envelope, Englisch für Hüllkurve Envelope, Englisch für ein Hüllprotein in der Virushülle Environment, Englisch allgemein für Umwelt oder Umgebung env (von Englisch Environment), ein Unix Befehl zum Anzeigen… …   Deutsch Wikipedia

  • Env — La commande UNIX env permet d afficher toutes les variables d environnement de l utilisateur courant. v · d · …   Wikipédia en Français

  • ENV — europäische Vornorm; sie darf als beabsichtigte Norm zur vorläufigen Anwendung auf technischen Gebieten mit hohem Innovationsgrad herausgebracht werden. Eine ENV darf veröffentlicht werden, auch wenn nur eine Sprachfassung vorliegt. Sie ist nach… …   Erläuterung wichtiger Begriffe des Bauwesens

  • ENV — The ENV (Emission Neutral Vehicle) is an electric motorcycle prototype powered by an hydrogen fuel cell. [cite web url = http://www.youtube.com/watch?v=buNjfuVicyo title=Fuel cell motorcycle youtube.com accessdate=2006 10 11] It is being… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”