executing a command with PHP in windows
Moderator: General Moderators
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
executing a command with PHP in windows
whats the syntax like for executing a command? i have a script on a slave drive i need to be able to access another file on another drive on the same computer via the web. is it possible?
take a look at http://www.php.net/manual/en/ref.exec.php
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
thanks, my kraut eating brother! heres my problem, when i run some script i wrote i get the confirmation no "1" back meaning it was succesful but the changes it was to make didnt work. i did this, can you tell me whats wrong with it?
<?
echo "test adding user...";
system("cmd /c cd c:\program files\serv-u", $test1);
system("cmd /c servuadm.exe -ma -ujubbajoo -ppassword", $test2);
echo $test1 . ", " . $test2 . ".<br>";
echo "test complete, check for new user, jubbajoo";
?>
im still fiddling, so laugh it it makes you feel good. me noob to higher PHP type code.
<?
echo "test adding user...";
system("cmd /c cd c:\program files\serv-u", $test1);
system("cmd /c servuadm.exe -ma -ujubbajoo -ppassword", $test2);
echo $test1 . ", " . $test2 . ".<br>";
echo "test complete, check for new user, jubbajoo";
?>
im still fiddling, so laugh it it makes you feel good. me noob to higher PHP type code.
I doubt 1 means success, normally it's a return value of 0.
Each system-call stands for itself. Your second command has nothing to do with the first (+you're opening a new command-processor for each with cmd /c
).
tryinstead
Each system-call stands for itself. Your second command has nothing to do with the first (+you're opening a new command-processor for each with cmd /c
try
Code: Select all
echo system("c:\\program files\\serv-u\\servuadm.exe -ma -ujubbajoo -ppassword", $retval), ' ', $retval;;-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
maybe by using exec() and sneaking up to it 
Code: Select all
<pre><?php
$out = array();
exec("dir", $out);
print_r($out);
$out = array();
exec("dir c:", $out);
print_r($out);
$out = array();
exec("dir c:\\program files\\serv-u", $out);
print_r($out);
$out = array();
exec("dir c:\\program files\\serv-u\\servuadm.exe", $out);
print_r($out);
$out = array();
exec("c:\\program files\\serv-u\\servuadm.exe -ma -ujubbajoo -ppassword", $out);
print_r($out);
?></pre>-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
here are the results of that trial:
new testArray ( [0] => Volume in drive D is WEBROOT [1] => Volume Serial Number is 386E-1AD9 [2] => [3] => Directory of d:\AUBURNSKIES\rs\customermanagement [4] => [5] => 01/01/2003 03:40a
. [6] => 01/01/2003 03:40a
.. [7] => 01/01/2003 03:40a 375 queries.php [8] => 01/16/2003 10:00a 1,533 ftpadmintest.php [9] => 2 File(s) 1,908 bytes [10] => 2 Dir(s) 3,283,456,000 bytes free )
Array ( )
Array ( )
Array ( )
Array ( )
done
, 0
test complete, check for new user, jubbajoo
new testArray ( [0] => Volume in drive D is WEBROOT [1] => Volume Serial Number is 386E-1AD9 [2] => [3] => Directory of d:\AUBURNSKIES\rs\customermanagement [4] => [5] => 01/01/2003 03:40a
. [6] => 01/01/2003 03:40a
.. [7] => 01/01/2003 03:40a 375 queries.php [8] => 01/16/2003 10:00a 1,533 ftpadmintest.php [9] => 2 File(s) 1,908 bytes [10] => 2 Dir(s) 3,283,456,000 bytes free )
Array ( )
Array ( )
Array ( )
Array ( )
done
, 0
test complete, check for new user, jubbajoo
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
could it be that i have like drive traversing turned off in the PHP.ini? is that possible?
or should i peak around in IIS?
its VERY possible i restricted that sort of access, BUT, my SQL database runs off that drive...but i think that the sqlAdmin utility i use to access that database runs off the C drive cuz for some reason it wouldnt run off of d. i wonder if i should try moving the scripts to the c drive and exec' them from there.
or should i peak around in IIS?
its VERY possible i restricted that sort of access, BUT, my SQL database runs off that drive...but i think that the sqlAdmin utility i use to access that database runs off the C drive cuz for some reason it wouldnt run off of d. i wonder if i should try moving the scripts to the c drive and exec' them from there.
these are the only two settings I know of having an effect on this (which doesn't mean there are morephp.ini wrote:;
; Safe Mode
;
safe_mode = Off
; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
;
;open_basedir =
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact:
-
fujiwara takumi
- Forum Newbie
- Posts: 10
- Joined: Wed Jan 15, 2003 4:04 pm
- Location: racine, wi
- Contact: