我需要从PHP脚本的强制上下文中调用可执行文件.无论是性能还是安全性,最好不要在Web服务器进程和可执行文件之间调用shell.
当然,我搜索了网络,没有成功(在这样的PHP上下文中).许多其他语言允许并清楚地记录它.
唉,反引号,exec(),shell_exec(),passthru(),system(),proc_open(),popen()叫壳.而pcntl_fork()似乎不可用.
这是在Debian 6 64bit和PHP 5.3.3-7 + squeeze15上测试的.在http://pastebin.com/y4C7MeJz上测试代码
为了获得有意义的测试,我使用了一个技巧,即要求执行一个shell命令,该命令也不能作为可执行文件使用.一个很好的例子是umask.任何返回类似0022的函数肯定称为shell.exec(),shell_exec(),passthru(),system(),proc_open()都做到了.请参阅http://pastebin.com/RBcBz02F上的详细结果.
现在,回到目标:如何在不启动shell的情况下执行任意程序?
Php的exec按预期采用字符串args数组而不是唯一字符串.但pcntl_fork只是在没有日志的情况下停止请求.
编辑:pcntl_fork失败是因为服务器使用Apache的mod_php,请参阅http://www.php.net/manual/en/function.pcntl-fork.php#49949.
编辑:popen()按照@hakre建议添加到测试中.
任何暗示赞赏.
我有以下清单
var list = new List<IMyCustomType>();
list.Add(new MyCustomTypeOne());
list.Add(new MyCustomTypeTwo());
list.Add(new MyCustomTypeThree());
Run Code Online (Sandbox Code Playgroud)
这个过程有效,但我想知道如何使用一个语句来声明列表并填充值?
谢谢
确认 VLC 可以从本地给定的 SDP 文件播放流。
根据证词,这似乎是可能的:
于是找了一个公开的案例,找到了Mobile Streaming、RTSP/RTP、Wowza Streaming Engine | Wowza 媒体系统。
这有效,播放带声音的彩色视频:
vlc rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
Run Code Online (Sandbox Code Playgroud)
我设法使用网络技巧提取了 SDP 文件- 如何捕获单个进程的网络流量?- 询问 Ubuntu
strace -f -e trace=network -s 10000 mplayer rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov 2>&1 | grep a=
Run Code Online (Sandbox Code Playgroud)
...然后重新格式化文件并保存到 bbb.sdp
文件看起来像(实际行不以空格开头,并以 Windows 样式的行结尾结束):
o=- 785981631 785981631 IN IP4 184.72.239.149
s=BigBuckBunny_115k.mov
c=IN IP4 184.72.239.149
t=0 0
a=sdplang:en
a=range:npt=0- 596.48
a=control:*
m=audio 0 RTP/AVP 96
a=rtpmap:96 mpeg4-generic/12000/2
a=fmtp:96 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1490
a=control:trackID=1
m=video …Run Code Online (Sandbox Code Playgroud) 我正在尝试从a读取数据,以下TcpClient是我的工作方式:
var client = tcpListener.AcceptTcpClient();
var data = new byte[client.ReceiveBufferSize];
StringBuilder dataString = new StringBuilder();
using (var ns = client.GetStream())
{
while (ns.Read(data, 0, client.ReceiveBufferSize) != 0)
{
dataString.Append(Encoding.UTF8.GetString(data));
}
}
client.Close();
Run Code Online (Sandbox Code Playgroud)
问题是我的字符串长度不是8192(这是值client.ReceiveBufferSize),因此我\0在StringBuilder中附加了很多.
我怎样才能获得确切的数据量?
从const C ++ std :: map获取条目无法在gcc 5.4.0上编译。
test_map.cpp: In function ‘int main()’:
test_map.cpp:9:24: error: passing ‘const std::map<int, int>’ as ‘this’ argument discards qualifiers [-fpermissive]
foo[key];
Run Code Online (Sandbox Code Playgroud)
// Compile with
// g++ test_map.cpp -o test_map
#include <map>
int main() {
const std::map<int, int> foo;
foo[0]; // compiles if "const" above is suppressed
}
Run Code Online (Sandbox Code Playgroud)
这看起来与传递'const相似,此参数将丢弃约a Cache而不是a的限定符[-fpermissive]std::map。原因在于:用户调用write()方法。该方法未声明const,因为编写可能会修改该对象,所以该方法有意义。
但是在这里,从地图中获取元素不会修改地图,对吗?
在我的实际用例中,实际的映射确实是const。它已在源代码中完全初始化。修改它没有任何意义。声明为非常量实际上可以解决问题,但没有任何意义。
我正在使用2个vlc库AxAXVLC和AXVLC.所以我可以在我的c#winform应用程序中添加vlc控件.在这个应用程序中,我可以通过添加播放列表和调用API播放来播放rtsp视频流.但我不能播放视频文件.播放视频流的代码如下.这是工作.请帮我播放视频文件.
axVLCPlugin21.playlist.items.clear();
string Options3 = ":rtsp-caching=250"; //Cache in mS
int stream1 = axVLCPlugin21.playlist.add("rtsp://10.1.114.51:8554/test", axVLCPlugin21, Options3);
axVLCPlugin21.playlist.playItem(stream1);
Run Code Online (Sandbox Code Playgroud) 我想显示一个a指向一个节点的节点b。b位于子图中。以下点图可视化代码应该可以工作。
digraph
{
a;
subgraph cluster_mysubgraph
{
a->b;
}
}
Run Code Online (Sandbox Code Playgroud)
唉,虽然节点a是在任何子图之外声明的,但它是在内部渲染的mysubgraph(在 Ubuntu 14.04 上的 graphviz 2.36.0 上观察到):

我尝试过诸如预声明b之类的变体。没有成功。
解决方法是在另一个集群子图中声明a。
digraph
{
subgraph cluster_pseudo
{
a;
}
subgraph cluster_mysubgraph
{
a->b;
}
}
Run Code Online (Sandbox Code Playgroud)
这可以防止a出现在 内部mysubgraph,但另一个子图并不是真正的选择。

a实际上应该在任何子图之外。
c# ×2
vlc ×2
.net ×1
c#-4.0 ×1
c++ ×1
connection ×1
const ×1
dictionary ×1
dot ×1
graphviz ×1
initializer ×1
libvlc ×1
list ×1
performance ×1
php ×1
rtsp-client ×1
sdp ×1
security ×1
shell ×1
subgraph ×1
tcpclient ×1
tcplistener ×1