php - 从 shellscript 检索 cmd 到 php,但使用 pgsql select 或 ssh select
问题描述
您好,我在运行 shell 脚本时尝试检索查询数据,如何打印信息?
以这种方式执行我得到回报。
结果
total 20
-rw-r--r-- 1 root root 876 Aug 22 13:05 Index.html
-rw-r--r-- 1 root root 462 Aug 22 13:05 index2.html
-rw-r--r-- 1 root root 48 Aug 22 13:05 layout.css
-rw-r--r-- 1 root root 69 Aug 22 13:05 promp.php
-rw-r--r-- 1 root root 60 Aug 22 13:05 teste.sh
我的php
<?php
$output = shell_exec('ls -l');
echo "<pre>$output</pre>";
?>
我试过的命令不起作用。
<?php
$output = shell_exec('psql -X -A -d totalipdb -U totalip -h 10.11.12.193 -t -c "select * from trunks where phone_number = '080078795';"');
echo "<pre>$output</pre>";
?>
检索错误
localhost cannot fulfill this request at this time.
HTTP ERROR 500
直接在终端运行我返回了查询结果,但是php显示错误
解决方案
推荐阅读
- javascript - 以简单的方式为业余爱好者提供 Javascript API / 文件处理?
- entity-framework - 如何建立单向关系?
- stored-procedures - SSRS 报告返回的行数少于它调用的存储过程
- cmake - 如何使用来自 bitbake 配方的 qemu 运行程序?
- python - 对数刻度的 Seaborn 带状图
- java - Spring Boot Dashboard 不会在 VSCode 上显示 App
- node.js - mongodb如何在数组中查找字符串的长度
- javascript - 如何使用 fetch API 在 javascript 中下载具有多个块的单个文件
- excel - 使用具有特殊字符的路径执行 objExcel.Application.Run 时出现问题
- python-3.x - Gtk 问题:ModuleNotFoundError: No module named 'gtk'