Web Producer w/ Brilliance
Aquent
US-CA-San Rafael

Justtechjobs.com Post A Job | Post A Resume

Replacing Perl Scripts with PHP Scripts
Introduction
With the introduction of version 4.2, PHP has started supporting a new SAPI (Server Application Programming Interface) called CLI (Command Line Interface). This facility was introduced to help developers create small shell applications (scripts) with PHP. So, now you can kiss Perl goodbye forever.
The CLI SAPI was released for the first time with PHP 4.2.0, but was still experimental back then and had to be explicitly enabled with --enable-cli when running ./configure. With PHP 4.3.0 the CLI SAPI will no longer be experimental and therefore will always be built and installed as the php (called php.exe on Windows) binary.
What is PHP Shell Scripts?
Normally shells are interactive, but not always. It means the shell will accept commands from you through keyboard and execute them. But instead of issuing commands one by one we can store this sequence of commands into a text file and tell the PHP to execute this text file instead of entering the commands. This is known as PHP shell scripting.
A PHP Shell script is just like batch file is MS-DOS but has more power than the MS-DOS batch file, thanks to PHP.
Why Write Shell Scripts?
  1. Shell scripts can take input from a user or a file and output them to the screen.
  2. Useful to create our own commands/application.
  3. Don't have to reinvent the wheel.
  4. To automate some day to day tasks.
In this tutorial we shall learn how to use PHP's CLI feature to interpret shell scripts, we assume that you have fair understanding of PHP and that PHP is installed and working properly on your computer, you can have PHP installed on Linux or Windows (the examples in this tutorial are demonstrated with PHP installed under Windows but they should work the same on Linux machine)
[ Next Page ]


Comments:
ThanksJeremy08/13/07 12:14
±â³×½ººÏ µµÀü, 100¹è »¡¶óÁö°í ½¬¿öÁø ¿µ¾î¿ø¸® ÀÌÈÆ±â11/16/05 00:54
Ä«/µå/ºú!ÀÌ·¸°Ô/ÇØ°áÇϼ¼¿ä±èÁø¼÷03/23/05 09:52
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÇýÁø12/07/04 11:23
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø12/06/04 02:33
Ä«,µå,¿¬,ü,ÀÚ/¿¹.Á¤.ÀÚ ´ë,Ãâ 100-1000¸¸¿øÀÌ´ÙÇö12/05/04 10:49
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæ¿í12/05/04 03:01
½Å.¿ë.ºÒ.·®/Ä«.µå.¿¬.ü/´ë.Ãâ/È¥ÀÚ/ÇØ.°áÇÏ´Â/¹æ.¹ý±èÇö¼­11/28/04 03:49
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø11/27/04 23:24
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæ¹Î11/23/04 20:43
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÁ¤¿¬11/18/04 20:52
Ä«.µå.±ø.¾È.ÇÏ.°í.µ·.¸¸.µé.¾î.¾².´Â.ºñ.¹ýÀÌÈñÁø11/15/04 12:57
Need HelpManoj Mitra11/13/04 05:15
php script to validate mobile number and emaivijay07/01/04 16:47
´ëÃâ °ÅÀý½Ã 100%µÇ°ÔÇÏ´Â ¹æ¹ý(Çʵ¶)!!!¼Û´ÙÈñ01/22/04 06:47
´ëÃâ °ÅÀý½Ã µÇ°Ô ÇÏ´Â ¹æ¹ý!!!¼­ÇöÈñ01/07/04 09:04
½Å¿ëºÒ·®/Ä«µå¿¬Ã¼/È¥ÀÚÇØ°áÇÏ´Â ¹æ¹ý!!(Çʵ¶) µµ¿ì¹Ì10/04/03 04:04
Can't start itMagnus Bergmark04/28/03 12:00
RE: But why?Clay Neudeck03/14/03 18:52
But why?J Hilton02/19/03 13:12
Important: CGI != CLI...philip olson12/16/02 13:59
RE: Can't reaplce Perl totallyTom12/13/02 11:02
RE: Daemon?Jason12/03/02 10:35
Daemon?Spot11/28/02 02:31
Some pointsKjartan Mannes11/26/02 09:40
RE: CLI new?Kjartan Mannes11/26/02 09:02
RE: Excutable PHP in Unix SystemJason11/25/02 09:10
Wondeful ArticleRaj Kambli11/22/02 17:47
RE: .exe incoming ;DJason11/21/02 10:08
Excutable PHP in Unix SystemAfif11/21/02 03:19
Seriously underrated use of PHPS Clark11/20/02 13:23
RE: Great articleDario Fumagalli11/19/02 10:14
RE: Great articleepplestun11/19/02 06:19
Very goodepplestun11/19/02 06:18
RE: Great articleepplestun11/19/02 06:05
.exe incoming ;DRipman11/18/02 16:33
ummm ....Anonymouse11/18/02 10:17
executableR. Vermeersch11/16/02 15:19
Can't reaplce Perl totallyBahwi11/15/02 15:52
RE: Great articleBDKR11/15/02 15:38
RE: Great articleJayesh Jain11/13/02 17:24
CLI new?Steve Werby11/13/02 17:04
Great articleN. Elsten11/12/02 11:09
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.