PHP File Finding shell_exec Versus exec Plus Tutorial

PHP File Finding shell_exec Versus exec Plus Tutorial

PHP File Finding shell_exec Versus exec Plus Tutorial

Yesterday’s PHP File Finding Signed Time shell_exec Versus exec Tutorial, and postings before it considered “exec” …

  • to be related to the PHP function exec (a favourite of ours) … but then, we introduce today, the idea of “exec” as a …
  • command line (on Linux or unix or macOS) find command switch “exec” switch …

    -exec command ;
    Execute command; true if 0 status is returned. All
    following arguments to find are taken to be arguments to
    the command until an argument consisting of `;’ is
    encountered. The string `{}’ is replaced by the current
    file name being processed everywhere it occurs in the
    arguments to the command, not just in arguments where it
    is alone, as in some versions of find. Both of these
    constructions might need to be escaped (with a `\’) or
    quoted to protect them from expansion by the shell. See
    the EXAMPLES section for examples of the use of the -exec
    option. The specified command is run once for each
    matched file. The command is executed in the starting
    directory. There are unavoidable security problems
    surrounding use of the -exec action; you should use the
    -execdir option instead.

… that we start improving upon for those Linux or unix or macOS users to see information about via hovering over the “result set” table presented (via title attribute).

So, feel free to try the changed find_minus.php‘s live run link also available here below.


Previous relevant PHP File Finding Signed Time shell_exec Versus exec Tutorial is shown below.

PHP File Finding Signed Time shell_exec Versus exec Tutorial

PHP File Finding Signed Time shell_exec Versus exec Tutorial

The recent PHP File Finding shell_exec Versus exec Tutorial, on the Linux and/or unix and/or macOS side of functionality, did not factor in the choice of …

  • +

… signage possibilities for the “find” command we use via PHP’s exec function. The “man find” tells us

-atime n
File was last accessed less than, more than or exactly
n*24 hours ago. When find figures out how many 24-hour
periods ago the file was last accessed, any fractional
part is ignored, so to match -atime +1, a file has to have
been accessed at least two days ago.

… that not involving these “time signage” ideas (we add in a new dropdown), by choosing a blank sign could be causing you not to see files you expected if you had included one of these signs.

And so, feel free to try the changed find_minus.php‘s live run link also available here below.


Previous relevant PHP File Finding shell_exec Versus exec Tutorial is shown below.

PHP File Finding shell_exec Versus exec Tutorial

PHP File Finding shell_exec Versus exec Tutorial

Lots of software based desktop application problems are centred around the finding of files via a time based criteria. With this in mind, today, we combine …

… whether that be related to …

  • file modified time
  • file access time
  • file created time
  • file inode creation time

That sort of “find” file finding functionality find_minus.php‘s live run link can be a part of a “housekeeping” type of scheduled job, such as described via a crontab entry such as …


04 3 * * * ksh -c 'for i in `find ./PHP/animegif -name "0*.php" -mtime +7`; do rm -f $i; done'


Previous relevant PHP shell_exec Versus exec Tutorial is shown below.

PHP shell_exec Versus exec Tutorial

PHP shell_exec Versus exec Tutorial

Being suckers for “out of the box” solutions to programming issues, what comes “out of the box” with your (perhaps underlying) operating system of use is always inflicting “sucker punches” onto areas we didn’t know existed before … well, you had to be there, didn’t you?

That’s why we really like PHP’s “exec” and “passthru” that we have used quite a bit in the past, to get through to that underlying operating system set of commands in its command line environment, as applicable. Even mobile platforms get a go here, because PHP is a serverside language addressing the RJM Programming linux web server, though you can download s_e.php to your local (client) environment, and access a different perspective in an Apache/PHP/MySql local web server environment such as MAMP to work in.

Today, we compare “shell_exec” to “exec” with our proof of concept PHP web application we’ve written for you to try today, for you to see that “shell_exec” is everything “exec” is plus returning the entire command line command’s output, as distinct from the “just last line return” of exec …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *