[英]How to run WP-CLI using bash script in linux
I'm having issue to run bash script setting up WP-CLI by it's own. 我在运行bash脚本以自行设置WP-CLI时遇到问题。 Keep on getting wp no command found error.
继续获取wp找不到命令错误。 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. 它只运行到exec bash行。 after that its not installing any plugin.
之后,它不会安装任何插件。 Please help.
请帮忙。
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. exec bash
正在打开一个新的阻止程序。
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
不在PATH
,则可以使用/usr/local/bin/wp
的完整路径代替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
: 或者,您可以将此路径添加到
PATH
:
export PATH="${PATH}:/usr/local/bin/wp"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.