Bacula-users

Re: [Bacula-users] Job canceling tip

2013-03-05 09:57:58
Subject: Re: [Bacula-users] Job canceling tip
From: Dan Langille <dan AT langille DOT org>
To: <bacula-users AT lists.sourceforge DOT net>
Date: Tue, 05 Mar 2013 09:54:06 -0500
On 2013-03-04 04:42, Konstantin Khomoutov wrote:
> On Mon, 4 Mar 2013 08:45:05 +0100
> Geert Stappers <Geert.Stappers AT vanadgroup DOT com> wrote:
>
> [...]
>> Thank you for the tip. I want to share another.
>> It is about canceling multiple jobs. Execute from shell
>>
>>    for i in {17..21} ; do echo cancel yes jobid=404${i} | bconsole ;
>> done
>>
>> Five jobs, 40417-40421, will be canceled.
>
> A minor nitpick: the construct
>
> for i in {17..21}; do ...
>
> is a bashism [1], so it won't work in any POSIX shell.

A good point! I tried the above on FreeBSD:

$ cat test.sh
#!/bin/sh

for i in {17..21} ; do echo cancel yes jobid=404${i} ; done


[dan@bast:~/bin] $ ./sh test.sh
cancel yes jobid=404{17..21}
[dan@bast:~/bin] $

>
> A portable way to do the same is to use the `seq` program
>
> for i in `seq 17 21`; do ...
>
> or to maintain an explicit counter:
>
> i=17
> while [ $i -le 21 ]; do ...; i=$(($i+1)); done

Then I tried this approach but didn't find seq at all.  I tried sh, 
csh, and tcsh.

But I know about jot.  This does 5 numbers, starting at 17:

$ jot 5 17
17
18
19
20
21

Thus, the script becomes:

$ cat test.sh
#!/bin/sh

for i in `jot 5 17` ; do echo cancel yes jobid=404${i} ; done


$ sh ./test.sh
cancel yes jobid=40417
cancel yes jobid=40418
cancel yes jobid=40419
cancel yes jobid=40420
cancel yes jobid=40421



-- 
Dan Langille - http://langille.org/

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>