> From [EMAIL PROTECTED] Wed Aug  2 11:23:42 2000
> Date: Wed, 02 Aug 2000 13:15:03 -0400
> From: "William R. Knox" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: LPRng: A small change in behavior
>
> I just noticed a small change in behavior in LPRng (version 3.6.22) that
> is impacting my log analysis. When you specify something like
>
> as=jobstart $-P $-t $-h $-j $-b $-n
>
> it no longer wraps the resultant information in single quotes (i.e. you
> end up with a line like "jobstart printer date server id size user"
> instead of "jobstart 'printer' 'date' 'server' 'id' 'size' 'user'"). If
> you instead use
>
> as=jobstart $P $t $h $j $b $n
>
> it does wrap them in single quotes, but with the initial flag (i.e.
> "jobstart '-Pprinter' '-tdate' '-hserver' '-jid' '-bsize' '-nuser'") as
> advertised. Did I miss something in the CHANGES file, or is it a
> fiddling little bug, which happens to be making my log analysis space
> out when it hits names with spaces (i.e. Macs)?

Use the $P form above.
If you are using Perl you can use the following little
gem that was sent to me by somebody:

my(%options);
while( <> ){
        chomp line;
        %options=();
        while( s/ [-']+(\w)'*([^']+)'//g ){
                $options{$1}=$2;
        }
        if( /start/ ){
          #handle the start stuff
        } elsif( /end/ ){
      #handle the end stuff
    }
}

If you want to pull just one out, you can use:
        $value = $1 if / [-']+X'*([^']+)'/;

where X is the letter corresponding to the option.

This is one of the reasons I love Perl so much.

Perl:  No two users do it the same way.

If you are using C, then you can use:

while( fgets(input, strbuf, sizeof(strbuf) ){
        if( (s = strchr(strbuf,'\n')) ) *s = 0;
    for( s = strbuf; s && ( (s = strstr( s, " -'")) || (s = strstr( s, " '-")) ); s = 
t ){
                s += 3;
                if( (t = strchr(s,'\'') ){
                        *t++ = 0;
                }
                c = *s++;
                /* now you have c == option and s -> the option value */
                ... and you handle the options the way you want
    }
}

>
> I'm going to get a reputation as a whiner on this list, aren't I? ;-)

No, no.  You ask GOOD questions.  And you read the manual!

> -- 
>                       Bill Knox
>                       Senior Operating Systems Programmer/Analyst
>                       The MITRE Corporation

Patrick Powell                 Astart Technologies,
[EMAIL PROTECTED]            9475 Chesapeake Drive, Suite D,
Network and System             San Diego, CA 92123
  Consulting                   858-874-6543 FAX 858-279-8424 
LPRng - Print Spooler (http://www.astart.com)

-----------------------------------------------------------------------------
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to