Using UNC paths ... //RemoteServer/Directory
I can use the php.exe to read the directory fine from the command line. But when I run it from the web page with the exec call it fails. I will post the code below. I suspect that this is a perms issue. BUT I have made the directory readable by the SYSTEM user which is what apache runs under I believe. Here is the code sample ... I can run dircmd.php from the command line successfully but when I try to get the webserver to execute it with dirtest.php it fails.
dirtest.php
Code: Select all
<?php
$pnl = "Dir1";
$cst = "Dir2";
exec('php-win.exe dircmd.php '.$pnl.' '.$cst,$out);
//pclose(popen('start /b dircmd.php '.$pnl.' '.$cst, 'r'));
//exec('start /b php -v',$out);
print_r($out);
?>
dircmd.php
<?php
$pnl = $argv[1];
$cst = $argv[2];
if(!isset($argv[1]) || !isset($argv[2])) {
exit("ERROR need to pass in pnl cust!");
}
$pth = "\\\\FileServer1\\DirLevel1\\DirLevel2";
$dir = $pth."\\".$pnl."\\".$cst;
if (is_dir($dir)) {
$fp = fopen("C:\\Documents and Settings\\user\\Desktop\\dir","w");
fwrite($fp,"OK");
fclose($fp);
$out = "OK";
} else {
$fp = fopen("C:\\Documents and Settings\\user\\Desktop\\dir","w");
fwrite($fp,"NOT-OK ".$pnl." ".$cst." ".$dir);
fclose($fp);
$out = "NOT-OK";
}
return $out;
?>Can anyone help. I'm sorry if this is the wrong place, but this seems like a program architecture problem more than a coding issue. Let me know if you feel this post is misplaced.
THX g
Burrito: Please use
Code: Select all
tags when [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting PHP Code In The Forums[/url][/size]