0

I'm having issue to run bash script setting up WP-CLI by it's own. Keep on getting wp no command found error. Please help.

#!/bin/bash
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
exec bash
wp --info
wp plugin install taxonomy-terms-order --path=/var/www
wp plugin activate taxonomy-terms-order --path=/var/www

It's only running till exec bash line. after that its not installing any plugin. Please help.

Thenesh
  • 13
  • 5

1 Answers1

0

Do not hesitate to make small experiments to understand the problem:

$ cat test.sh 
#!/bin/bash

echo "Test 1"
exec bash
echo "Test 2"
$ echo $$
6506
$ ./test.sh 
Test 1
$ echo $$
6548

exec bash is opening a new blocking process.

So, I think you can remove this line from your script.

If /usr/local/bin is not in your PATH, you can use the complete path of /usr/local/bin/wp instead of wp :

/usr/local/bin/wp --info
/usr/local/bin/wp plugin install taxonomy-terms-order --path=/var/www
/usr/local/bin/wp plugin activate taxonomy-terms-order --path=/var/www

Or you can add this path to the PATH:

export PATH="${PATH}:/usr/local/bin/wp"
Idriss Neumann
  • 3,760
  • 2
  • 23
  • 32