Results 1 to 2 of 2

Thread: accept input from shell pipe into php cli script?

  1. #1
    Join Date
    Oct 2005
    Location
    USA
    Beans
    308
    Distro
    Ubuntu 8.10 Intrepid Ibex

    accept input from shell pipe into php cli script?

    so i basically want my php command line script to be able to accept one of its arguments from a shell pipe, like grep, for instance:

    Code:
    ls | grep .jpg
    sorts out all the jpegs in the output from ls

    i want to be able to do something similar but instead of grep, with my php script, for instance:

    Code:
    ls | grep .jpg | myscript.php
    or some such business (that's actually accurate since the script resizes jpeg files)

    i tried google but i can't think of specific enough search terms, i get a lot of unrelated matches, thanks!
    what happened? where am i?
    http://www.wellactually.net/code

  2. #2
    Join Date
    Jul 2006
    Beans
    363
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: accept input from shell pipe into php cli script?

    This page discusses the ability to do command line arguments:

    http://www.phpfreaks.com/tutorials/86/1.php

    What you may have to do is:

    you could then use a "dir" in php with the command line argument to pull your ls instead, just call it from the command line in the folder you're wanting it pulled from like this:

    Code:
    myscript.php .jpg
    Make sense?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •