LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using bash shell script inside php (https://www.linuxquestions.org/questions/linux-newbie-8/using-bash-shell-script-inside-php-853185/)

lakshman.1043 12-30-2010 01:30 AM

Using bash shell script inside php
 
Hi,

Can anyone tell how do i use bash shell scripts inside php.
I am just trying to call a simple cp command using php. Its not doing anything.

Any help would be appreciated.

paulsm4 12-30-2010 01:34 AM

"system()" or "eval" should do the trick.

Be very careful executing system commands from a PHP-based web page - it could be a HUGE security risk!!!

Disillusionist 12-30-2010 01:41 AM

Copying and Renaming files can be done directly through PHP

Code:

<?php
  $source = "/path/to/filea";
  $destination = "/path/to/new/filea";

  if( copy($source, $destination) )
    { mesg = "Copied $source to $destination<br/>"; }
  else
    { mesg = "Failed to copy $source to $destination<br/>";}
?>
<html><head><title>Testing...</title></head>
  <body>
  <?php echo($mesg); ?>
  </body>
</html>

To rename use the command rename in place of copy


All times are GMT -5. The time now is 03:36 PM.