LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-30-2010, 02:30 AM   #1
lakshman.1043
LQ Newbie
 
Registered: Dec 2010
Posts: 1

Rep: Reputation: 0
Cool 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.
 
Old 12-30-2010, 02:34 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"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!!!
 
Old 12-30-2010, 02:41 AM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
how to stop parsing shell variables in bash script inside cat area? jackandking Linux - Newbie 2 03-10-2009 07:44 AM
Execute bash script inside PHP creatorrr Programming 11 11-21-2007 05:32 PM
run shell script bash from browser with php achilles Programming 10 08-02-2007 04:44 PM
Can I execute a shell script from inside a php one. prabhatsoni Linux - Software 2 05-24-2006 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration