ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.


PHP in the Command Line

(Page 1 out of 4)

There's a single line you can add to your web host's control panel that will automatically archive your content.

Ever run commands in DOS? You've used a shell. A "shell" in the computer world is a place where you enter commands and run files by name rather than clicking around different windows.

Most web hosts let you operate a shell remotely. This means that you can type commands in window on your computer, that are actually run on your web host, thousands of miles away.

I'd like you to log in to your shell now. If you can't do it by going in to DOS and typing "telnet", your web host probably uses "SSH" -- a secure shell. You'll have to ask your host how you can log in to the shell, they might tell you to download a program called "PuTTY" and give instructions how to use it.

If you can't login to your shell, or aren't allowed, you'll just have to sit back and watch what I do.

Now that you're logged in, type: echo hi

On the next line will be printed hi

Try this: date +%Y

This prints the current year. That's 2004 for me.

So what if we combined the two? Try: echo date +%Y

Well, that doesn't work, because the computer thinks you're trying to echo the TEXT "date +%Y" instead of the actual COMMAND. What we have to do here is surround that text in what are called "back quotes". Unix will evaluate everything enclosed in back quotes (by evaluate, I mean it'll treat that text as if it were entered as a command.)

Your back quotes key should be located on the upper-left corner of your keyboard, under the Esc button.

Next: Pipe down, over there.. »

Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Introduction
  2. Pipe down, over there..
  3. Put it together
  4. What are arguments?
Bookmark Article
Download Article
Download this article as a PDF file