在php中管理卷曲输出(managing curl output in php)
如何在PHP中隐藏curl的输出?
我的代码如下:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERPWD, PSSWDINFO); $result= curl_exec ($ch); curl_close ($ch);
问题出在整个页面,怎么只能显示一个“成功”或“失败”的消息?
How do I hide the output from curl in PHP?
My code as it stands is the following:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERPWD, PSSWDINFO); $result= curl_exec ($ch); curl_close ($ch);
The problem is that is spews out the entire page, how can I simply show a "success" or "failed" message?
原文:https://stackoverflow.com/questions/1234537
最满意答案
一种方法可能是编写自己的
gethostbyaddr()
函数,将其编译到一个库(比如libmyfunc.so
)中,然后将其预加载到包装脚本中,以便供应商的安装程序使用它而不是系统gethostbyaddr()
:#!/bin/bash export LD_PRELOAD=libmyfunc.so export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH /path/to/crappy_vendor_binary $@
One way might be to write your own
gethostbyaddr()
function, compile it into a library (say,libmyfunc.so
), then preload it in a wrapper script so the vendor's installer uses it rather than the systemgethostbyaddr()
:#!/bin/bash export LD_PRELOAD=libmyfunc.so export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH /path/to/crappy_vendor_binary $@
相关问答
更多-
更改作为映像安装的Windows系统的主机名/ IP地址(Changing Hostname / IP Address of Windows System Mounted as an Image)[2022-08-09]
您可以使用chntpw工具离线编辑Windows注册表。 这是一个如何使用它的例子。 你正在寻找的关键是这些: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName HKEY_LOCAL_MACHINE\SYSTEM\Current Control Set\ Services\Tcpip\Parameters\Interfaces\{} 在你的界面的GUID下你会找到许多键,你需 ... -
在Linux / Bash / Perl中将主机名屏蔽到IP地址查找(masking hostname to IP address lookup in Linux/Bash/Perl)[2022-07-20]
一种方法可能是编写自己的gethostbyaddr()函数,将其编译到一个库(比如libmyfunc.so )中,然后将其预加载到包装脚本中,以便供应商的安装程序使用它而不是系统gethostbyaddr() : #!/bin/bash export LD_PRELOAD=libmyfunc.so export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH /path/to/crappy_vendor_binary $@ One way might be to write ... -
>>> import socket >>> socket.gethostbyaddr("69.59.196.211") ('stackoverflow.com', ['211.196.59.69.in-addr.arpa'], ['69.59.196.211']) 为了在函数上实现超时, 这个stackoverflow线程有这样的答案。 >>> import socket >>> socket.gethostbyaddr("69.59.196.211") ('stackoverflow.com', ['2 ...
-
解析主机名的IP地址(Resolving ip-address of a hostname)[2023-10-16]
看看InetAddress和getHostAddress()方法。 InetAddress address = InetAddress.getByName("www.example.com"); System.out.println(address.getHostAddress()); Take a look at InetAddress and the getHostAddress() method. InetAddress address = InetAddress.getByName("www. ... -
在JavaScript标准库中没有主机或IP地址的概念。 所以你必须访问一些外部服务来为你查找主机名。 我建议托管一个cgi-bin,它查找主机名的ip地址,并通过javascript访问。 There's no notion of hosts or ip-addresses in the javascript standard library. So you'll have to access some external service to look up hostnames for you. I re ...
-
您可以使用系统调用gethostbyname()来解析主机名,然后使用返回的结构来获取IP地址。 看看最后一部分的inet_ntop() 。 示例代码 struct hostent *hostentry; hostentry = gethostbyname("google.com"); char * ipbuf; ipbuf = inet_ntoa(*((struct in_addr *)hostentry->h_addr_list[0])); printf("%s",ipbuf); You can us ...
-
更改主机名bash脚本(Change hostname bash script)[2024-01-04]
我找到了解决方案。 感谢@anubhava - 我还修复了原始示例中的一些不一致问题: #!/bin/sh echo "Changing hostname to IP-related" HNAME=ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d. -f4 | awk '{ print $1 }' echo "Proposed hostname is: $HNAME" echo hostname $HNAME echo "The new ... -
getnameinfo() - 反向DNS查找(IP地址到主机名)C / C ++(getnameinfo() - Reverse DNS lookup (IP Address to hostname) C/C++)[2023-04-02]
在调用inet_pton时,您正在使用struct sockaddr ,但调用签名要求这是AF_INET的struct in_addr (或IPv6的struct in6_addr )。 然后你必须使用它为后面的函数构建struct sockaddr 。 按照目前的情况,您将在包含实际IP地址的字段之前将地址的一些字节写入字段,因此您最终只得到sockaddr字段中IP的最后2个八位字节。 You are using a struct sockaddr when calling inet_pton but ... -
在Linux中将IP映射到主机名(Map IP to hostname in linux)[2022-03-31]
你的意思是/ etc / hosts文件吗? /etc/hosts 典型的条目可能如下所示: 127.0.0.1 localhost 127.0.0.1 sagan 192.168.1.87 bohr Do you mean the /etc/hosts file? /etc/hosts Typical entries might look like: 127.0.0.1 localhost 127.0.0.1 sagan 192.168.1.87 bohr -
如何从类似于/ etc / hosts的文件中获取IP地址的主机名(How to get hostname from IP address from file similar to /etc/hosts)[2022-05-26]
你可以尝试: sh script.sh listofip #!/bin/bash echo "IP ?" echo -n "(Value and press Enter) :" read ip while read line do #VARIABLES file1=$line mip=$(echo $file1 | awk '{print $1}') name=$(echo $file1 | awk '{print $2}') if [ " ...