Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

PHP in the Command Line

By Robert Plank
2005-05-25


Pipe down over there

Type this in: echo `date +%Y`

Gives us "2004".  You could even do something like this: echo `dir`

Which puts the directory listing all on one line.

But now, we put our newfound knowledge to good use.  Unix has another neat feature called piping, which means "take everything you would normally output to the screen here, and shove it whatever file I tell you to."  So say I had something like this:

echo "hey" > test.txt

Now type "dir" and you'll see a new file, test.txt, that wasn't there before.  View it off the web, or FTP it to your computer, do whatever you have to, to read the file.  It should contain the word "hey".

Likewise, dir > test.txt would store the directory listing into "test.txt".

Tutorial Pages:
» Listen closely and you'll hear the ocean
» Pipe down over there
» Here today, gone tomorrow
» Put it together
» Arguments (not the shouting kind)


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1

Ask A Question
characters left.