Sponsor-Board.de
Linux Script .SH Programmierungsfrage

+- Sponsor-Board.de (https://www.sponsor-board.de)
+-- Forum: Community (/forumdisplay.php?fid=56)
+--- Forum: Hilfe (/forumdisplay.php?fid=102)
+---- Forum: Linux-Server (/forumdisplay.php?fid=105)
+---- Thema: Linux Script .SH Programmierungsfrage (/showthread.php?tid=54211)


Linux Script .SH Programmierungsfrage - SkyGamer - 20.03.2015 13:16

Hallo zusammen.

Ich bin gerade mal wieder an meinem kleinen Hosting System und überlege derzeit, wie ich das hallo aus:

Code:
./test.sh -s hallo


Also das in meinem Code $s = Argument 3 ist.

Weiß jemand, was man da Googlen sollte bzw. Hat jemand gute Links?

Vielen Dank für euren guten Support :-)
Daniel

Ps.: Gerade ausm Kopf:

Code:
#!/bin/sh

$name = $2;

case "$1" in
        -s)
                echo "Teste Screen - Name:" + $name"
                ;;
        *)
                echo "Verwende: ${0} {-s}"
                exit 2
esac
exit 0




RE: Linux Script .SH Programmierungsfrage - moser96 - 20.03.2015 22:07

Hallo,
ich habs jetzt einfach mit Ifs gemacht. Verwende die immer da sie leicht und zuverlässig sind. Ich hoffe ich konnte dir helfen:

PHP-Code:
#!/bin/sh

name=$2
param
=$1

if [ $# -eq 2 ] && [ $param = "-s" ]
then
        
echo "Teste Screen - Name: $name"
else
        echo 
"Verwende: ${0} {-s}"
fi