Am Dienstag, 23. Februar 2010 12:50:41 schrieb Pierre Gaston: > On Tue, Feb 23, 2010 at 1:14 AM, DanielBu <i...@bunzendahl.net> wrote: > > Hello all, > > > > I get crazy with getopts: > > Some Times my script (500 Lines) don't take input parameters like this: > > It's really impossible to make a guess with a report as vague as that. >
#!/bin/bash while getopts ':b:d:f:l:o:vh' OPTION ; do case $OPTION in v) VERBOSE=y ;; b) pdffront="$OPTARG" ;; d) BOOKLET="$OPTARG" echo "Booklet: "$BOOKLET ;; f) FSEITE="$OPTARG" ;; l) LSEITE="$OPTARG" ;; o) FORMAT="$OPTARG" ;; h) usage $EXIT_SUCCESS ;; \?) echo "Unbekannte Option \"-$OPTARG\"." >&2 usage $EXIT_ERROR ;; :) echo "Option \"-$OPTARG\" benötigt ein Argument." >&2 usage $EXIT_ERROR ;; *) echo "Dies kann eigentlich gar nicht passiert sein..." >&2 usage $EXIT_BUG ;; esac done # Verbrauchte Argumente überspringen shift $(( OPTIND - 1 )) # Eventuelle Tests auf min./max. Anzahl Argumente hier if (( $# < 1 )) ; then echo "Du hast was vergessen (evtl. PDF-Datei oder Argument für einen Schalter)" >&2 usage $EXIT_ERROR fi case $BOOKLET in 4) papersizex=500 papersizey=700 scalerate=90 scalerateif=90 ;; 5) papersizex=420 papersizey=595 scalerate=90 scalerateif=50 ;; 6) papersizex=298 papersizey=420 scalerate=90 scalerateif=25 ;; *) papersizex=500 papersizey=700 scalerate=90 scalerateif=90 ;; esac echo "Breite x Höhe: "$papersizex"x"$papersizey resthight=$papersizey restbreite=$papersizex echo "Restbreite x Resthöhe: "$restbreite"x"$resthight booklet_page="1" booklet_page_counter="1" # Schleife über alle Argumente for ARG ; do if [[ $VERBOSE = y ]] ; then echo -n "Argument: Ich bin eine V-erquasseltes Bash-Script" fi echo "Argument: " $ARG done pdf=$1 if [ !$LSEITE ]; then LSEITE=$(pdfinfo $pdf | grep Pages: | sed -e 's/Pages:[[:space:]]//g') echo "-l automatisch auf $LSEITE gesetzt" fi ... ------------------------------------------------------------------------------------------------ and so on (500 lines... so I don't show it all) In the last if-loop LSEITE will be set if LSEITE isn't set. This is for no parameters on command-line. But how I wrote: It ever works.... but now it lost the -l 104 ... the -f is no Problem... My question wasn't fokused on my wrong script. I think there is something wrong or limited by the System... Maybe you can give me a tip I should search for... Thanks a lot Daniel :-) -- Mit fitten und gesunden Grüßen Daniel Bunzendahl http://www.Bunzendahl.net Umsatzsteuer-Identifikationsnummer: 08132/03257 Unsere Empfehlung: http://www.wsim.de/ref.php?id=16436 (Manager Game) ================================== Hinweis: Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder dieses E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. --- NOTICE: This e-mail may contain confidential or privileged material and is intended for use solely by the above-referenced recipient. Any review, copying, printing, disclosure, distribution, or other use by any other person or entity is strictly prohibited. If you are not the named recipient, or believe you have received this e-mail in error, please reply to the sender and delete the copy you received. Thank you.