Re: How to run bconsole commands in a bash for loop?

Sebastian Suchanek <[email protected]>
Newsgroups gmane.comp.bacula.user
Message-ID <[email protected]>
Am 16.09.2025 um 18:39 schrieb Gary Dale:

> [...]
> So I'm trying to run a bash
> script to cycle through them to purge them.
> 
> I've found multiple answers that suggest using a bash for loop then
> doing something like:
>           echo "purge volume ${volname} yes" | bconsole  - where $volname
> is created by the for loop -
> should work. And it does actually to a point. It will invoke the "purge
> volume" dialogue then asks which pool to use. Inserting the pool number
> after the volume command (e.g. echo "purge volume 2 ${volname} yes" |
> bconsole) doesn't work either. Nor does inserting \n into the echoed
> command at various points.
> 
> Being able to put bconsole commands into a bash script seems like
> something that will be generally useful but I can't find a way to make
> it work.
> 
> Any ideas?

This works for me in a slightly different scenario:

------------------ cut here ------------------

bconsole <<END_OF_COMMANDS
release storage=LTO1-Drive


quit
END_OF_COMMANDS

------------------ cut here ------------------

Note the "empty" lines between the lines with the release and the quit 
command which "simulate" pressing return. However, I'm not sure if you 
can use variable within this "here document" structure or if the 
variable name will be interpreted as verbatim input. In the latter case, 
you might, for example, first create a temporary script file with the 
appropriate commands and run that from your main script. (Yes, sounds 
like an ugly hack...)


HTH,

Sebastian


_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.