Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对 Bash 和 Shell 脚本不是很熟悉,但我的长期目标是编写一个 bash 脚本,该脚本将从 MySQL 表中获取数据。对于找到的每个结果,我都想执行一个扩展名为“?result=bashvariable”的 PHP 文件。
我将如何在 bash 中获取 SQL 数据并将其存储在变量中?
在 PHP 中,我会简单地获取结果并运行一个 while 循环,我只是想知道这是否可以使用 bash?
如果这是某种重复,我深表歉意,但我还没有找到我正在寻找的答案。
mysql -e 'yourquery' database | while read bashvariable do php file.php "$bashvariable" done
PHP 脚本可以将 bash 变量作为$argv[1].
$argv[1]