1

I have a series of curl commands I use to warm varnish using a script. The individual commands work just fine on the command line but when I put those same commands in a script they don't work.

#!/bin/bash
curl -o /dev/null --insecure -X PURGE -H 'X-Magento-Tags-Pattern: ((^|,)cat_p_123456(,|$))' https://www.example1.com/page1.html --resolve www.example1.com:443:127.0.0.1
curl -o /dev/null --insecure -I -X GET 'https://www.example1.com/page1.html'

On the command line I can run these commands individually and they work as expected. The first command purges the cache, the second warms the cache. When I visit the page after running these on the command line I get the expected hit cached.

If I put these in a shell script, make it executable and run with ./script.sh or even /bin/bash script.sh the purge works but the get doesn't. I get a cache miss.

nbucko
  • 21
  • 2
  • Try adding `set -v` and/or `set -x` at the start of your script to see what is going on. – vonbrand Mar 14 '20 at 01:04
  • Maybe there's a delay needed between the two commands – A.B Mar 14 '20 at 22:28
  • @vonbrand The only thing I can see is that the command that gets displayed by set -x is dropping the single quotes on the GET request. – nbucko Mar 15 '20 at 20:42

1 Answers1

0

Try this variant:

#!/bin/bash
curl -o /dev/null --insecure -X PURGE -H 'X-Magento-Tags-Pattern: ((^|,)cat_p_123456(,|$))' https://www.example1.com/page1.html --resolve www.example1.com:443:127.0.0.1 && curl -o /dev/null --insecure -I -X GET 'https://www.example1.com/page1.html'
Oxyd
  • 126
  • 6