# Bash - Exploitation d'un argument

**URL:** <https://www.debian-fr.org/t/bash-exploitation-dun-argument/86444>\
**Category:** Programmation\
**Created:** [Avril 24, 2022, 10:23 UTC](https://www.debian-fr.org/t/bash-exploitation-dun-argument/86444 "2022-04-24T10:23:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbreton](https://www.debian-fr.org/user_avatar/www.debian-fr.org/vbreton/32/11400_2.png) [@vbreton](https://www.debian-fr.org/u/vbreton)\
**Post date:** [Avril 24, 2022, 10:23 UTC](https://www.debian-fr.org/t/bash-exploitation-dun-argument/86444/1 "2022-04-24T10:23:19Z")

</div>

Bonjour,  
Si j’écris en dur le nom dans le script bash, la ligne de commande de création d’un VM fonctionne bien mais pas quand je le passe en argument de mon script.

```auto
#!/usr/bin/env bash
NAME=\"$1\"
#VBoxManage createvm --name "Linux Debian Bullseye" --ostype "Debian_64" --register
VBoxManage createvm --name $NAME --ostype "Debian 64" --register
echo $NAME

```

---

<div class="post-metadata">

**Author:** ![dindoun](https://www.debian-fr.org/user_avatar/www.debian-fr.org/dindoun/32/4281_2.png) [@dindoun](https://www.debian-fr.org/u/dindoun)\
**Post date:** [Avril 24, 2022, 12:09 UTC](https://www.debian-fr.org/t/bash-exploitation-dun-argument/86444/2 "2022-04-24T12:09:05Z")

</div>

```auto
#!/usr/bin/bash
NAME="$1"
#VBoxManage createvm --name "Linux Debian Bullseye" --ostype "Debian_64" --register
VBoxManage createvm --name "$NAME" --ostype "Debian 64" --register
echo "$NAME"

```

a priori la règle doubles guillemets marche bien dans tous les cas ( la simple non)

---

<div class="post-metadata">

**Author:** ![vbreton](https://www.debian-fr.org/user_avatar/www.debian-fr.org/vbreton/32/11400_2.png) [@vbreton](https://www.debian-fr.org/u/vbreton)\
**Post date:** [Avril 24, 2022, 12:33 UTC](https://www.debian-fr.org/t/bash-exploitation-dun-argument/86444/3 "2022-04-24T12:33:41Z")

</div>

Elle marche effectivement ici. Merci @dindoun.
