>>>>> On Fri, 14 Mar 2025 14:21:15 +0000, Bill Arlofski via Bacula-users said:
> 
> In a script, you can do:
> 
> 
> echo -e "sql\nSELECT......ORDER BY volumename INC;\n\nquit\n" | bconsole
> 
> 
> The echo -e: enable interpretation of backslash escapes
> 
> The `\n` in the script are line feeds.  The two `\n\n` in a row get you out 
> of the bconsole SQL interface.

Beware that echo is a minefield.  Support for the -e option (and even handling
of \ without -e) is not standardized across all shells.  For example, /bin/sh
on Debian defaults to dash, which doesn't support -e and always treats \n as a
newline.  This is the opposite of bash.

The simplest solution is use the POSIX printf utility instead of echo.

If you still think echo is a good idea and want to be sure to get newlines,
then you can use multiple commands:

( echo "sql"; echo "SELECT......ORDER BY volumename INC;"; echo; echo "quit" ) 
| bconsole

__Martin


_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to