mardi 6 octobre 2015

Bash if-Statement always triggers "then..."

I already checked other people's questions and although I followed the advice given to them, my script still doesn't work.

I want to ping an ip-adress if my script gets the parameter "test" and test wether the target is reachable or not.

If the script is executed without a command I want to send a WakeOnLan-package.

Here is my code:

#!/bin/bash

if [ "$1"="test" ];
then
    if ping -c 5 -i 1 192.168.178.27; then echo "Desktop is reachable"; else echo "Desktop not (yet) reachable"; fi

else
    echo "sending magic package"
    sudo wakeonlan FC:AA:14:E7:CD:95
fi

Aucun commentaire:

Enregistrer un commentaire