Click to See Complete Forum and Search --> : [RESOLVED] exec() not working for lan


acemo
03-02-2006, 07:22 AM
I am trying to read the content of a file, placed on "c:\username.txt"
however, this file is stored on a other compter in the network...

I can manually read the content of the file, using cmd:

type \\192.168.1.101\c$\username.txt


however, when i try this command trough exec:

echo exec('type \\192.168.1.101\c$\username.txt');

it returns nothing...

so, i tested if exec could not use the command type:

echo exec('type c:\username.txt');

however, this did display the content of the local stored file..

how can i read the content of this remote file?


EDIT: replaced "" quotes for '' quotes at the exec commands cuz using $ there.
that didnt solved tho.

NogDog
03-02-2006, 11:30 AM
Why not just use readfile(), include, or require instead of exec()'ing an OS command?

acemo
03-02-2006, 12:10 PM
The remote file is not stored on a webserver but on a client pc in the local intranet.

This was the only way i could think off, using the administrative share c$ to get into the c: drive..

acemo
03-07-2006, 08:25 AM
This works.
the problem was at first i used $getusername ="\\"; resulting in only one backslash.
Thus the script not being able to find the computer.

plz note, apache needs admin rights on the network to be able to use the C$ share.


$ipaddress = $_SERVER['REMOTE_ADDR'];
$getusername = "\\\\";
$getusername .= $ipaddress;
$getusername .= "\c$\username.txt";
$myfile = substr(file_get_contents("$getusername"),0,-2);