Re: Variable getopts lost

2010-02-23 Thread Mart Frauenlob
On 23.02.2010 20:55, Daniel Bunzendahl wrote:
> Am Dienstag, 23. Februar 2010 20:45:31 schrieb Greg Wooledge:
>> On Tue, Feb 23, 2010 at 08:30:16PM +0100, Daniel Bunzendahl wrote:
>>> if [ !$LSEITE ]; then
>>
>> You want:  if [ ! "$LSEITE" ]
> 
> this dosn't work.
> 
> But I earsed the if-loop. And it works. (dont overwrite LSEITE)
> But I need this check in case somebody will put last page to work with...
> 
> maybe I try thinks like
> 
> test  
> 
> If I don't find a way, I will ask again.
> Thanks for your time :-)
> 
> Gratings
> Daniel
> 
>> There are probably more errors.  This is just the line you mentioned
>> in particular as not working.
>>
> 

use the '[[' conditional command. you don't need to quote the variables
with it.

if [[ ! $var ]]; then ...

if ! [[ $var ]]; then ...

if [[ -z $var ]]; then ...

if [[ ! -n $var ]]; then ...

if ! [[ -n $var ]]; then ...

Best regards

Mart


Re: Variable getopts lost

2010-02-23 Thread Daniel Bunzendahl
Am Dienstag, 23. Februar 2010 20:45:31 schrieb Greg Wooledge:
> On Tue, Feb 23, 2010 at 08:30:16PM +0100, Daniel Bunzendahl wrote:
> > if [ !$LSEITE ]; then
> 
> You want:  if [ ! "$LSEITE" ]

this dosn't work.

But I earsed the if-loop. And it works. (dont overwrite LSEITE)
But I need this check in case somebody will put last page to work with...

maybe I try thinks like

test  

If I don't find a way, I will ask again.
Thanks for your time :-)

Gratings
Daniel

> There are probably more errors.  This is just the line you mentioned
> in particular as not working.
> 

-- 
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.




Re: Variable getopts lost

2010-02-23 Thread Ken Irving
On Tue, Feb 23, 2010 at 08:30:16PM +0100, Daniel Bunzendahl wrote:
> ...
> if [ !$LSEITE ]; then 
>  LSEITE=$(pdfinfo $pdf | grep Pages: | sed -e 's/Pages:[[:space:]]//g')
> echo "-l automatisch auf $LSEITE gesetzt"
> fi
> ...
> 
> 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 :-)

Note that 'if [ !$LSEITE ]' becomes 'if [ ! ]' if LSEITE is not set, and
the value is true.  Maybe that's what you want, but a better way is to use
the -n or -z test operators and to *quote the variable expansion*, e.g.,

if [ -z "$LSEITE" ]; then ...

Unquoted variables expand to nothing, and are evaluated as such.
Perhaps there are other such cases in your script?

Ken





Re: Variable getopts lost

2010-02-23 Thread Greg Wooledge
On Tue, Feb 23, 2010 at 08:30:16PM +0100, Daniel Bunzendahl wrote:

> if [ !$LSEITE ]; then 

You want:  if [ ! "$LSEITE" ]

There are probably more errors.  This is just the line you mentioned
in particular as not working.




Re: Variable getopts lost

2010-02-23 Thread pk
Daniel Bunzendahl wrote:

> 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...

You've got it already...either invoke the script with its name (not through 
bash), or use bash -- etc.


Re: Variable getopts lost

2010-02-23 Thread Daniel Bunzendahl
Am Dienstag, 23. Februar 2010 12:50:41 schrieb Pierre Gaston:
> On Tue, Feb 23, 2010 at 1:14 AM, DanielBu  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.




Re: Variable getopts lost

2010-02-23 Thread Pierre Gaston
On Tue, Feb 23, 2010 at 1:14 AM, DanielBu  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.


Re: Variable getopts lost

2010-02-23 Thread Mart Frauenlob
On 23.02.2010 00:14, DanielBu wrote:
> 
> Hello all,
> 
> I get crazy with getopts:
> Some Times my script (500 Lines) don't take input parameters like this:
> 
> /bin/bash pdf2media.sh -f 9 -l 104 Document.pdf
> 
> the script reads -f 9 and Documents.pdf but missing -l 104
> 
> It did work for a log time - I know there was a problem some times bevor.
> After reboot everything was OK - but this didn't help at this time.
> Also a trick to get dim. of an jpeg putten into a $jpegdimx fails ...
> 
> Info by the way: The script gets via pdfimages surprising more then 10
> Images ...
> maybe this crashes something?
> 
> I've googled this - but no real results.
> 
> Please help - I worked 3 Month for this script.
> Thanks a lot :-)
> Daniel 

Did you try `bash -- pdf2media.sh -f 9 -l 104 Document.pdf'?


Variable getopts lost

2010-02-22 Thread DanielBu

Hello all,

I get crazy with getopts:
Some Times my script (500 Lines) don't take input parameters like this:

/bin/bash pdf2media.sh -f 9 -l 104 Document.pdf

the script reads -f 9 and Documents.pdf but missing -l 104

It did work for a log time - I know there was a problem some times bevor.
After reboot everything was OK - but this didn't help at this time.
Also a trick to get dim. of an jpeg putten into a $jpegdimx fails ...

Info by the way: The script gets via pdfimages surprising more then 10
Images ...
maybe this crashes something?

I've googled this - but no real results.

Please help - I worked 3 Month for this script.
Thanks a lot :-)
Daniel 
-- 
View this message in context: 
http://old.nabble.com/Variable-getopts-lost-tp27695401p27695401.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.