Wednesday, September 8, 2010

Perform HTTP-GET via Curl Commands inside PHP

PHP supports libcurl that allows you to connect and communicate to many different types of servers with many different types of protocols.

libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, and user+password authentication.

Now the fun begins.

$url = 'API server host';
$curl;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_URL, $url);
$result = curl_exec($curl);
curl_close($curl);
header('Content-Type: application/xml; charset=ISO-8859-1');
print $result;


By default, curl makes use of HTTP-GET unless explicitly specified to be false and as HTTP-POST method.

Thursday, June 3, 2010

Find text within files on Linux



cd /your_directory
find . -type f -exec grep -l "string to find" {} \; -print


Easy!


Saturday, May 15, 2010

Problem using vtysh

checking for main in -lreadline... no
configure: error: vtysh needs libreadline but was not found and


solution:
just install readline-devel !!!


Install packages under a different destination directory

we can install packages under a different destination directory by using the DESTDIR variable during make install, with a command like

make install DESTDIR=/tmp/myfolder


Install packages under a different destination directory

We can install packages under a different destination directory by using the DESTDIR variable during make install, with a command like

make install DESTDIR=/tmp/myfolder