- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
所需信息:我在家用 PC 网络服务器 Fedora 20 上运行它,并使用来自 yum 存储库的 httpd。我从以下位置获取了 .cgi 文件的基本版本:http://www.instructables.com/id/Simple-linux-commands-from-a-web-page/并一直在尝试修改它以满足我的需要。
我的问题 - 我可以非常轻松地使 cgi 脚本运行 uname、lspci、ls 以及/usr/bin 文件夹中仅显示文本的任何脚本。然而,我不能运行一个实际上做某事的脚本。例如,我无法让 cgi 运行“rhythmbox-client --next”来在 Rhythmbox Media Player 上快进一首歌曲。
我的意图:我为我的 friend ventrilo 服务器运行一个“音乐机器人”,我想为他们提供(受密码保护的)方式从网络访问该机器人、更改歌曲、将歌曲添加到播放队列等。
我需要的功能(我无法使用这些功能)是:下一首歌曲(rhythmbox-client --next)上一首歌曲 (rhythmbox-client --previous)将歌曲添加到队列(rhythmbox-clinet --enqueue NAME)清除歌曲队列(rhythmbox-client --clear-queue显示当前播放的歌曲(rhythmbox-client --print-playing)显示计算机上的歌曲列表 (ls/home/user/Music | grep ".mp3")
尽我所能,我无法让这些事情发挥作用。我也尝试过使用 Banshee 而不是 Rhythmbox,也有同样的问题。
假设执行命令的脚本部分如下: echo “” echo“精英音乐机器人控制面板” PATH="/bin:/usr/bin:/usr/ucb:/usr/opt/bin" 导出$PATH echo “” 回显“”
# test if any parameters were passed
if [ $CMD ]
then
case "$CMD" in
BotInfo)
echo "<pre>"
/bin/BotInfo
echo "System Name:" `/bin/uname -n`
echo "</pre>"
;;
next)
echo "Skipped to the next song."
/bin/rhythmbox-client --next
;;
back)
echo "Repeating the previous song. <pre>"
/bin/rhythmbox-client --previous
echo "</pre>"
;;
playing)
echo "The current song playing is... <pre>"
rhythmbox-client --print-playing
echo "</pre>"
;;
queue)
echo "The requested song has been added to the queue. <pre>"
rhythembox-client --enqueue $QUEUE_SONG
echo "</pre>"
;;
rating)
echo "The rating of the current song has been set to $RATING. <pre>"
/bin/rhythmbox-client --set-rating $RATING
echo "</pre>"
;;
ls)
echo "<pre>"
list=`ls /home/USER/Music | grep ".mp3"`
echo "$list"
echo "</pre>"
;;
*)
echo "Unknown command $CMD<br>"
;;
esac
fi
第一个是一个简单的脚本,显示系统时间(日期)、cpuinfo、meminfo 等,它确实有效。然而其他人则不然。
我尝试将 bash 命令运行为
echo "$(command)"
对于打印播放,我尝试这样做:
playing=`rhythmbox-client --print-playing`
echo "$playing"
我还尝试创建一个脚本:
#!/bin/bash
echo "This command worked!"
rhythmbox-client --next
我将其命名为 rhynext,chmod +x 并移动到/usr/bin,当在终端中运行时它可以工作,当告诉 cgi 执行/usr/bin/rhynext 时它什么也不做。
请帮忙。
我足够聪明,可以对代码进行逆向工程,如果您可以简单地给我一个可以工作的代码段/示例,我很可能能够将其转换为我的用途。提前致谢。
编辑:当以 apache 用户身份运行 Banshee 的“下一个”脚本时..
sudo -u apache /usr/bin/next
[sudo] password for OMMITED:
Unhandled Exception: System.UnauthorizedAccessException: Access to the path "/usr/share/httpd/.config" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0
at System.IO.DirectoryInfo.Create () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0
at Hyena.Paths.InitializePaths () [0x00000] in <filename unknown>:0
at Hyena.Paths.set_ApplicationName (System.String value) [0x00000] in <filename unknown>:0
at Banshee.ServiceStack.Application.InitializePaths () [0x00000] in <filename unknown>:0
at Booter.Booter.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "/usr/share/httpd/.config" is denied.
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0
at System.IO.DirectoryInfo.Create () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:Create ()
at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0
at Hyena.Paths.InitializePaths () [0x00000] in <filename unknown>:0
at Hyena.Paths.set_ApplicationName (System.String value) [0x00000] in <filename unknown>:0
at Banshee.ServiceStack.Application.InitializePaths () [0x00000] in <filename unknown>:0
at Booter.Booter.Main () [0x00000] in <filename unknown>:0
最佳答案
问题源于节奏盒客户端期望连接到当前用户的 dbus session 来收集节奏盒信息/发出命令。 (感谢 Etan Reisner 指出这一点)
经过一番网上挖掘,我找到了解决方案。创建 2 个文件,一个用于在登录时将当前用户的 dbus session 地址保存到临时文件中,另一个用于调用 dbus 地址并通过它路由 CGI 命令。
文件 1:保留在所需文件夹中,添加到启动项,使可执行文件 (chmod +x) 名称为“Get.DBus.sh”
#!/bin/bash
set | grep DBUS_SESSION_BUS_ADDRESS > ~/.DBUS_temp
文件2:制作可执行文件,移动到/usr/bin,制作可执行文件(chmod+x)名称“Run.DBus.sh”
#!/bin/bash
source /home/USER/.DBUS_temp
export DBUS_SESSION_BUS_ADDRESS
$*
将CGI中所需命令的执行命令从..更改为..
command)
/bin/command
;;
致
command)
/bin/RunDBus.sh /bin/command
;;
问题已解决。所有命令都按预期工作。
感谢大家的帮助,万万没想到这是 DBus 问题 XD
关于linux - 通过 CGI 运行服务器端 Bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27302731/
我在使用 Jade 和 express 时遇到了一些问题。这是 serder 端: router.get('/login', function (req, res) { res.status(2
是否可以使用 JavaScript 服务器端,从而在某些核心计算中不会显示在页面源代码中? 我正在开发一款游戏,代码的一个关键部分只需要在服务器端计算然后传回客户端。 我的整个游戏都是用 Javasc
我正在寻找有关如何使用 ExtJS 4 实现安全页面的信息。我所说的安全页面是指用户将使用 Siteminder (SSO) 登录我们的网站,因此我们将拥有用户的身份。然后我们将通过进行数据库/LDA
我的 Centos 7 服务器正在运行 apache 2.4.6,并且正在使用 mod_wsgi 提供 django webapp。我的问题是我无法从另一台计算机的浏览器访问服务器 url。我没有从
我们收到了客户的请求,要求我们基于 ExtJS 框架构建 Web 应用程序。我查看了互联网,发现 ExtJs 只是一个客户端 javascript 控件,但我认为 Web 应用程序也必须具有服务器端
我有三个组件。 组件一包含组件二和三。 组件二是一个列表。 组件三用于向数据库添加项目。 当我将一个项目保存到数据库时,我想更新组件二中的列表。 我怎么做? 最佳答案 设想 让我们假设:
欢迎, 我正在寻找能使我以尽可能高的格式下载youtube视频的youtube api。 几年前,这项工作更为简单,因为url拥有关于质量的信息,例如“fmt = 22”或“fmt = 6”,我们现在
我想将电子邮件 x@x.com 的用户密码设置为“an”。但代码不起作用。这是我的云代码: Parse.Cloud.define('testSetPasswordForUser', functio
正在阅读http://cocoawithlove.com/2010/03/streaming-mp3aac-audio-again.html这篇文章,想知道如何在服务器端实现它,是否像将文件放在htd
我有一个使用一些 css/javascript 选项卡的 php 脚本,它们在我的本地服务器上运行,但当我上传到我的在线服务器时则不起作用。 只是想知道是否有人知道为什么会出现这种情况?所有路径都
是否可以从 JavaScript 脚本获取服务器端页面的源代码?我希望能够获取服务器上同一文件夹中的页面的源代码。除了javascript之外,是否可以不使用任何其他东西? 最佳答案 如果您想从 ja
.NET 4.0 我正在寻找在我们的服务器上生成Word文档的最简单方法。 局限性: 服务器端 我不想在服务器上安装word 数据源是XML 我试图用XSLT生成快速简单的DOCX,但是我可以找到的用
我正在使用 native jQuery 验证库来验证在联系表单中输入的电子邮件地址。由于这是一个表达式引擎站点,因此我使用其电子邮件验证器作为服务器端备份。 当我输入 test@b.c 时,jQuer
我使用带有服务器端处理的数据表来显示数万行。我需要通过复选框过滤这些数据。我能够制作一个工作正常的复选框,但我不知道如何添加多个复选框以协同工作。我找到了 similar solution在这里,但我
我正在尝试编写一个消息传递应用程序,并且我能够发送消息(显示为服务器客户端正确显示消息)但随后将我的客户端踢出服务器。服务器打印以下错误: java.io.EOFException at java.i
如果设备是移动设备,如何防止侧边栏加载服务器端资源?我了解如何通过 CSS 隐藏,但我更感兴趣的是防止对服务器的调用。 最佳答案 WordPress有一个名为wp_is_mobile()的函数它将检查
我有一个返回 text/event-stream 数据的网址,因此我尝试连接并打印我找到的所有内容: var url = "..." var source = new EventSource(url)
我得到这样的错误列表:{ error: [ "Email is required", "First Name is required"] } 我需要如何修改它,以获取包含字段名称的列表? public
我正在尝试使用 ASIFormDataRequest 将数据发送到 ASP.net 服务器端。我创建了一个aspx页面。目前我可以得到这两个纯文本。但是我不知道如何通过 Request.Form 在
我在 ${host}/api/graphql 有一个可通过 POST 访问的快速 graphql 端点。 在那条路线上,我有身份验证中间件,如果用户未登录,我想重定向到登录页面。 看起来有点像这样。
我是一名优秀的程序员,十分优秀!