banning in one line command
dridi at varni.sh
Wed Feb 1 16:25:12 CET 2017
On Wed, Feb 1, 2017 at 3:31 PM, Miguel González
<miguel_3_gonzalez at yahoo.es> wrote:
> Dear all,
> I have Varnish 4.1 and I´m trying to run in one single line command a
> ban for a particular website. If I run this:
> root at myserver [~] # varnishadm -T :6082 -S /etc/varnish/secret
> varnish> ban req.http.host ~ www.myserver.com
> I get the 200 code. However If I run it in a single line I get no 200
> return code:
> root at myserver [~] # varnishadm -T :6082 -S /etc/varnish/secret 'ban
> req.http.host ~ www.myserver.com'
You probably don't need the -T arg for a local access.
> I get nothing. If I try double quotes I get the same...
> I googled around and I find people asking the same but no solutions.
> What am I doing wrong?
Nothing wrong: what you are seeing in varnishadm's interactive shell
is the response status from varnish (see man varnish-cli) but when you
use varnishadm as a scripting command, only the actual output is
Instead of relying on the status code of the varnish-cli command, use
the exit status of the varnishadm command.
if ! varnishadm [...]
echo "varnishadm just failed" >&2
More information about the varnish-misc