liz
This user hasn't shared any biographical information
Posts by liz
What are the useful fields of $_SERVER array in PHP
Jan 12th
The following table describes useful fields in $_SERVER array in PHP.
Name Description PHP_SELF Returns the filename of the current script SERVER_PROTOCOL Name and revision of the information protocol ‘HTTP/1.0‘ or ‘HTTP/1.1′ REQUEST_METHOD Returns the request method used to access (GET/POST/PUT) REQUEST_TIME Returns the timestamp from the beginning DOCUMENT_ROOT Returns the root directory under which the current script is executing. This directory is based on server’s configuration. HTTP_REFERER Returns the page address that referred HTTP_USER_AGENT Returns the contents of user agent extracted from HTTP header. This information is typically used for identification of user’s browser and operating system. REMOTE_ADDR Returns the More >How to convert a relative path to an absolute path in bash
Jan 9th
The “readlink” command can be used to convert a relative path to an absolute path. Although readlink primarily for reading value of a symbolic link, it works transparently on files and directories.
[liz@techpulp ~]# readlink ../../var/www/wiki/index.php /usr/share/mediawiki/index.php [liz@techpulp ~]#
Let us see how it behaves for an invalid path (i.e missing file or directory).
[liz@techpulp ~]# readlink ../../var/www/wiki/index.php1 [liz@techpulp ~]#
As you can see, readlink command doesn’t print anything if the file or directory is not present. Because our intention is to just convert a relative path to absolute path and not to worry about its existence, we can use “-m” option More >
How to include a CSS stylesheet in another style sheet – Use import url statement
Dec 10th
You can use “import url(..)” statement to include a CSS file with in an another. For example, you can include another css file (file2.css) in a style sheet file file1.css by placing following statement in file1.css.
@import url(file2.css);
The above url is relative and file2.css is expected to be available at the same directory level as file1.css.
Otherwise you can specify a complete URL or a relative URL as shown in the following examples.
Import from a directory with absolute path on the same server:
@import url(/css/file2.css);
Import from a directory with relative path on the same server:
@import url(../css2/file2.css);
Import from another server using More >
How to redirect standard error to standard output in bash shell
Sep 30th
Any UNIX process, by default, will have three file I/O streams open. Each opened file of the UNIX process is denoted with a number called file number. The default opened three files streams are called stdin, stdout and sterr. Their file numbers are 0, 1 and 2 respectively. Of these stdin stands for standard input and meant for reading input from user or from another file. The stdout stands for standard output and any messages printed by the process get written to this file. Typically this file is console, so the user can use the messages printed by the process. More >
Where is my second CPU gone in Linux
Sep 8th
This was a weird problem that I faced when I installed Fedora 12 on my Intel 2140 Dual Core pc. The installtion went fine and Linux was working properly. But I discovered that Linux did not actually detect second CPU core when I examined /proc/cpuinfo. Earler I had used Fedora 10 which detected both the cores properly and worked well.
After doing some googling in the Internet, I found that Fedora 12 had disabled SMP mode during boot up and the problem can be rectified by placing “noapic acpi=off” in the Linux kernel command line options. Hmm.. The solution did work. More >
How to define local links in a web page
Aug 18th
The local links in a web page are called anchors.
To define an anchor in a HTML page, create a dummy “a” link as shown below.
<a id="chapter1"></a>
Create a link that user can click on to go to the previously defined anchor.
<a href="#chapter1">Chapter1</a>
How to run multiple commands at once in bash shell
Jun 24th
All commands can be just appended using a semicolon (;) to make the bash to run all the commands one after the other as shown below.
[liz@techpulp ~]# make config; make; make release
The above command is equivalent to running three commands “make config”, “make” and “make release” one after the other. The only difference is that you don’t need wait for one command to finish to type in the next command.
However if you have a series of dependant commands that require the previous command to succeed to execute the next command, you can change the command as shown below.
[liz@techpulp ~]# make More >
How to use “diff” utility effectively
Mar 4th
The command line tool “diff” helps you find differences between two files or directories. It also can report the differences between two directories including all files and sub directories recursively.
Compute differences between two files:
[neo@techpulp ~]# diff animals1.txt animals2.txt 4a5 > crane 8,9d8 < tiger < panda 16c15 < lion --- > lion roars [neo@techpulp ~]#
Whatever starts with “<” is the change in first file and whatever starts with “>” is the change in second file.
Compute differences between two files but ignore white spaces and blank lines:
[neo@techpulp ~]# diff -b -B animals1.txt animals2.txt
Compute differences between two directories:
[neo@techpulp ~]# diff dir1 dir2
Compute More >
Auto SSH login using ‘expect’ tool
Feb 28th
The “expect” tool can be used to achieve auto login for interactive commands like telnet, ftp, ssh and others. Automatic login is useful to avoid unnecessary delays in work and also useful in automation. However this method requires your password to be stored in the script in plain text. But you can set the file permissions so that you only can access it.
Using “expect” tool, we can spawn a command and expect certain messages from server and send user-defined strings to automate interactive prompts. So the script will be typically specific to a server because other server may prompt for More >


Recent Comments