LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 01: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, 01: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, 01:41 AM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

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



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 07:58 PM
how to stop parsing shell variables in bash script inside cat area? jackandking Linux - Newbie 2 03-10-2009 06:44 AM
Execute bash script inside PHP creatorrr Programming 11 11-21-2007 04:32 PM
run shell script bash from browser with php achilles Programming 10 08-02-2007 03:44 PM
Can I execute a shell script from inside a php one. prabhatsoni Linux - Software 2 05-24-2006 05:40 AM

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

All times are GMT -5. The time now is 08:21 PM.

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
Open Source Consulting | Domain Registration