LinuxGuruz
Toll Free Numbers
Custom Search
MAIN MENU
Main Page
IT Jobs
IPTABLES
Linux Forum
HTML Forum
PHP Forum
MySQL Forum
Linux FAQ
Linux Articles
About Us
Privacy Policy

ADD TO FAVORITES


MARC

Mailing list ARChives
- Search by -
 Subjects
 Authors
 Bodies





FOLDOC

Computing Dictionary






Cheap UK Web Hosting Provider

Cheap Dedicated Servers UK

Cheap Linux VPS Hosting UK

Cheap Cloud Hosting UK



Icons
Icons


free brochure template
Free Brochure Template

Web Hosting

Domain Names

Web Design

Reseller Hosting

Registro de Dominios

Reseller Hosting


Toll Free Number for $2.00/Month!!!

Toll Free Number for $2.00/Month!!!
Using backticks in PHP

Title:       Using backticks in PHP
Contributor: Randall Goguen (aka Ranman)
Last Update: Thusay June 22 02:00 EDT


Example 1:

# Get just the uptime from the uptime command.

<?= `uptime | awk '{print $3;}'` ?>


Example 2:

# Get your IP.

<?= `/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | \
awk '{print $2;}' | awk -F':' '{print $2;}'` ?>


Example 3:

# Get all but just the httpd proccess.

<?= `ps -ef | grep httpd | awk '{print $2}'` ?>


Example 4:

# List only files.

<pre><?= `ls -l | grep "^-"` ?></pre>
# or
<pre><?= `ls -l | grep "^-" | awk '{print $9;}'` ?></pre>


Example 5:

# Count only files.

<?= `ls -la |grep "^-" |awk 'END {print "Number of files: " NR}'` ?>


Example 6:

# List only directorys.

<pre><?= `ls -l | grep "^d"` ?></pre>
# or
<pre><?= `ls -l | grep "^d" | awk '{print $9;}'` ?></pre>


Example 7:

# Count only directorys.

<?= `ls -la |grep "^d" |awk 'END {print "Number of directories: " NR}'` ?>


Example 8:

# Find a file or directory.

<?
$file_name = "named.conf";
$directory_name = "/etc";
echo `find $directory_name -name $file_name -printf "Found file: %p "`
?>


Example 9:

# Count how many lines in a file.

<?= `wc -l /etc/named.conf` ?>


Example 10:

# Ping a IP twice.

<pre><?= `ping -c 2 127.0.0.1` ?></pre>


        Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org

        This document is Copyright (c) 1999, 2000 by LinuxGuruz

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page


www.PHP.net Search Engine


Restrict the search to:
Copyright © 1999, 2000 The PHP Development Team.
Submit a PHP Tutorial

Title:

Contributor:

IRC NICK: (optional)

E-Mail Address: (optional)

Tutorial:

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page

RESOURCE LINKS
Linux
Apache
HTML
PHP
MySQL
PostgreSQL
Oracle
CGI
Perl
Java
C/C++
Bash
Tcl
Networking
Security
ISP
IRC
Xwindow
Laptop
Graphics
Hardware
Reference
Misc

Broadband


filing cabinet

  • Buy Batteries for Laptops and Cameras
  • Notebooks
  • Michael Fertik
  • Reputation Defender

  • XP Style Icons
    XP Style Icons


    Network Certification


    Network Security


    Wireless Networking


    Canadian
    Web Hosting in Canada


    Drummer Portal


    Mending Media

    The Path Of
    Most Resistance


    Toll Free Number for $2.00/Month!!!

    Toll Free Number for $2.00/Month!!!


    Linux

    The Distributions





    Linux

    The Software





    Linux

    The News




    webmaster@linuxguruz.com
    Copyright © 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 and 2009 by LinuxGuruz