# \[RESOLU\]Exporter une variable d'un script shell

**URL:** <https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910>\
**Category:** Programmation\
**Created:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910 "2016-02-20T16:32:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![corsica13](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@corsica13](https://www.debian-fr.org/u/corsica13)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/1 "2016-02-20T16:32:40Z")

</div>

Bonjour a tous,

J’aimerai exporter une variable d’un script shell pour pouvoir y acceder de n’importe qu’elle autre script par le futur.

Mes tentatives avec la commande ‘export’ reste sans succès.

[quote]IPNET=$variable  
export IPNET[/quote]  
ou encore

> [@](#):
>
> export IPNET=$variable

Si vous avez une idée…

---

<div class="post-metadata">

**Author:** ![ed](https://www.debian-fr.org/user_avatar/www.debian-fr.org/ed/32/5886_2.png) [@ed](https://www.debian-fr.org/u/ed)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/2 "2016-02-20T16:32:41Z")

</div>

Il faut sourcer le script qui export, et non pas l’executer.

---

<div class="post-metadata">

**Author:** ![corsica13](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@corsica13](https://www.debian-fr.org/u/corsica13)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/3 "2016-02-20T16:32:42Z")

</div>

Désolé mais je ne comprends pas ‘sourcer le script’.

---

<div class="post-metadata">

**Author:** ![usinagaz](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/u/ecae2f/32.png) [@usinagaz](https://www.debian-fr.org/u/usinagaz)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/4 "2016-02-20T16:32:45Z")

</div>

bonjour,  
mettons que tu recueilles IPNET dans un fichier, donc qui va contenir :  
export IPNET=‘80.20.20.20.20’

tu le sources ainsi :

`$ source fichier` par exemple.  
Attention parce que tout ce qu’il contient est exécuté par le shell, si c’est une commande.

---

<div class="post-metadata">

**Author:** ![mattotop](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mattotop/32/3942_2.png) [@mattotop](https://www.debian-fr.org/u/mattotop)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/5 "2016-02-20T16:32:46Z")

</div>

autre syntaxe . fichier (point espace fichier)

---

<div class="post-metadata">

**Author:** ![corsica13](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@corsica13](https://www.debian-fr.org/u/corsica13)\
**Post date:** [Février 20, 2016, 4:32 UTC](https://www.debian-fr.org/t/resolu-exporter-une-variable-dun-script-shell/9910/6 "2016-02-20T16:32:48Z")

</div>

Merci pour votre aide, ca fonctionne !!!
