简体   繁体   English

如何在Linux中使用bash脚本运行WP-CLI

[英]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.

相关问题 Wordpress 升级:由于缺少 MySQL 扩展,无法使用 WP-CLI 从 Wordpress 3.8 更新到最新版本 - Wordpress Upgrade: Unable to update from Wordpress 3.8 to the latest using WP-CLI due to missing MySQL extension 如何编写将在Windows和Linux上运行的bash脚本 - How to write a bash script that will run on Windows and Linux 如何使用perl脚本和ssh在远程linux服务器中运行bash或shell脚本 - How to run a bash or shell script in a remote linux server using perl script and ssh 如何在Linux(ubuntu)中从bash脚本运行exec bash命令? - How to run exec bash command from the bash script in Linux (ubuntu)? 如何在Linux上使用Tmux使用bash脚本运行多个非结束命令 - How to use a bash script to run multiple non-ending commands on Linux using Tmux (Linux)bash脚本在延迟后运行脚本 - (linux) bash script to run script after delay 如何将变量替换为bash脚本,然后在Linux中的远程服务器上运行 - How to substitute variables into bash script and then run on remote server in Linux 使用 bash 脚本如何检查 aws cli 生成的 output 是否为空? - Using the bash script how to check if aws cli generated output is empty or not? 如何使bash脚本知道在Linux中执行的CLI程序的输出? - How do I make a bash script know the output of a CLI program it executed in Linux? 简单的bash Linux脚本来运行存储过程 - Simple bash Linux script to run stored procedure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM