pan-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pan-users] Automating NZB downloads


From: Duncan
Subject: Re: [Pan-users] Automating NZB downloads
Date: Wed, 9 Nov 2011 01:40:12 +0000 (UTC)
User-agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT bb16cbd /st/portage/src/egit-src/pan2)

Graham Lawrence posted on Tue, 08 Nov 2011 14:13:30 -0800 as excerpted:

>>>> Date: Sun, 06 Nov 2011 20:15:54 -0600
>>>> Excerpted From: Ron Johnson<address@hidden>
>>>
> 
>> That sounds like a weird use of arrays.
>>
> Its a great convenience.  If you have a list of items and you are
> interested only in one or two of them, using an array gives you
> instant identification of them, like so:-
> 
> IFS=$'\x0A'      # elements separated by line breaks only

This is definitely a personal style issue so it's not "wrong" by
any means, and you've likely already developed and are comfortable
with your style, but for others who might be following along, FWIW,
"in the field", I far more often seem to see something like this
(only a line-feed character between the quotes):

LF="
"

Then that can be used thruout the rest of the script, so:

IFS=$LF

BTW, I have a few scripts that change IFS from the default as well.
If you're using IFS, you're already doing reasonably advanced stuff
with your scripts. =:^)

> nzb=($(ls /home/g/dnlds/*.nzb))
> rm ${nzb[0]}     # ditch previous download
> pan --no-gui -o /home/g/Films --nzb "${nzb[1]}"      # make download
> IFS=$'\x20'$'\x09'$'\x0A'$'\x0D'      # reset default

Similarly here, I often see assignments of the space and tab chars
themselves.

Alternatively, the backslash-escaped forms can be used either in
single-quotes as above (but with the letter forms), or via echo -e:

IFS=$' \t\n'

IFS=$(echo -e " \t\n"

Of course, other ANSI C standard escapes are available as well.
The bash man and info pages cover the whole list, but \r
can be useful in combination with \n when dealing with
MS (or old-Mac) line-terminations (CRLF and CR, respectively,
Unix is of course LF), \e escape, \b backspace, octal, hex and
unicode value entries (you used the hex above), and even \cX
for control-X notation.

For many, either the literal characters within quotes, or the \X
letter notation will be easier to read than the \hHH or similar
hex/octal/unicode notation, so it could be preferred (where there
is such a version, of course) where others may be reading your code.

> Pretty much if I watch a movie, I download one, which minimizes the
> amount of HD I must devote to movies.  Otherwise they eat up the HD at
> a fantastic rate.  And its virtually all done with bash internals,
> which I think will be more efficient than calling a separate app like
> head (though its no big deal either way).

You're correct, but it's like the difference between taking a
helicopter or a taxi (or the public bus/train) the single-digit miles/km
to the launch-pad for a two-year trip to Mars and back.

That because the actual pan invocation for the download itself is
the trip to Mars.  The time and overhead for that is such that worrying
about an invocation of head or whatever is like worrying about whether
taking a taxi or the city bus to the launch pad is more efficient.

Well, at least unless you have an OC-3 or better at your disposal
(compare to an FTL warp-drive ship). =;^\

None-the-less, getting in the habit of thinking about efficiency
when it really doesn't matter will help you when it does, too. =:^)

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman




reply via email to

[Prev in Thread] Current Thread [Next in Thread]