473,378 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

run program or command using php

i want to run a unix/linux program with a php script.
i have two textbox named text1 and text2
and one button named execute.
if the button clicked then execute a unix command
like this :
execute( "cp text1 text2")

"cp" is unix command for copy
"text1" is directory source file to copy
"text2" is destination directory

how's the code looks like, write me an example.
Jul 23 '07 #1
2 2392
mwasif
802 Expert 512MB
Create a form. Check this link to how form works if you dont know http://www.w3schools.com/php/php_forms.asp.

On receiving submitted data, use exec() to run the commands

<?
$text1 = escapeshellcmd($_POST["text1"]);
$text2 = escapeshellcmd($_POST["text2"]);
exec("cp $text1 $text2")
?>

Use escapeshellcmd() to avoid any problems.
Jul 23 '07 #2
Create a form. Check this link to how form works if you dont know http://www.w3schools.com/php/php_forms.asp.

On receiving submitted data, use exec() to run the commands

<?
$text1 = escapeshellcmd($_POST["text1"]);
$text2 = escapeshellcmd($_POST["text2"]);
exec("cp $text1 $text2")
?>

Use escapeshellcmd() to avoid any problems.
thanks, i've follow that procedur, but nothings happen
here is my work

filename = fm_utdes.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5. <title>Form1 </title>
  6.  
  7.  
  8.  
  9. </head>
  10.  
  11. <body>
  12.  
  13. <form action="fm_prodes.php" method="post">
  14.  
  15.   <table width="350"  border="0" align="center" cellpadding="4" cellspacing="0" class="keliling">
  16.  
  17.     <tr align="left">
  18.  
  19.       <th colspan="2" scope="col"><div align="center">Form1</div></th>
  20.  
  21.     </tr>
  22.  
  23.     <tr>
  24.  
  25.       <td width="35%">Source file </td>
  26.  
  27.       <td>:      
  28.  
  29.       <input name="txt1" type="text" size="27" maxlength="50"></td>
  30.  
  31.     </tr>
  32.  
  33.     <tr>
  34.  
  35.       <td width="35%">final file </td>
  36.  
  37.       <td>:      
  38.  
  39.       <input name="txt2" type="text" size="27" maxlength="50"></td>
  40.  
  41.     </tr>
  42.  
  43.      <tr>
  44.  
  45.       <td>&nbsp;</td>
  46.  
  47.       <td><input type="submit">
  48.  
  49.  
  50.  
  51.     </tr>
  52.  
  53.   </table>
  54.  
  55. </form>
  56.  
  57. </body>
  58.  
  59. </html>
  60.  
and, this is for submit
filename = fm_prodes.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.                 $text1 = escapeshellcmd($_POST["txt1"]);
  3.         $text2 = escapeshellcmd($_POST["txt2"]);
  4.         exec("cp $text1 $text2");
  5. ?>
  6.  
Jul 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Arti Potnis | last post by:
Hi, I am trying to execute the DB2 load utility from a C program. lPid = fork(); execl(csExePath, csExeName,csCmd, NULL); the contents of the parameter variables are as follows:-
22
Frinavale
by: Frinavale | last post by:
How To Use A Database In Your Program Many .NET solutions are database driven and so many of us often wonder how to access the database. To help you understand the answer to this question I've...
1
Curtis Rutland
by: Curtis Rutland | last post by:
How To Use A Database In Your Program Part II This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts...
2
by: John Wright | last post by:
I have a central program I am starting to develop that will track processing deviations. This program is VB 2008 and needs to be called from VB 2005 programs and VB2008 programs (we have some VB 6...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.