• [^] # Re: utiliser eval ?

    Posté par . En réponse au message [RÉSOLU] Bash utiliser variable dans une commande du style result=$(commande | grep $variable). Évalué à 1.

    Je viens de tester avec le code suivant et ça fonctionne

    FONCTIONNE

    #!/bin/bash
    monPath="/media/cloud"
    su pi -c "mount $monPath"
    result=$(eval "mount | grep ${monPath} | wc -l")
    if [ $result = "1" ];then
     echo "montage effectif"
    else
     echo "montage not work"
    fi
    su pi -c "umount $monPath"

    NE FONCTIONNE PAS

    #!/bin/bash
    monPath="/media/cloud"
    su pi -c "mount $monPath"
    eval "mount | grep ${monPath} | wc -l"
    if [ $? = "1" ];then
     echo "montage effectif"
    else
     echo "montage not work"
    fi
    su pi -c "umount $monPath"

    Donation Bitcoin : 1N8QGrhJGWdZNQNSspm3rSGjtXaXv9Ngat