/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] exec() not working for lan

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:

[code]
type \192.168.1.101c$username.txt
[/code]

however, when i try this command trough exec:

[code=php]
echo exec(‘type \192.168.1.101c$username.txt’);
[/code]

it returns nothing…

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

[code=php]
echo exec(‘type c:username.txt’);
[/code]

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.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 02.2006 — Why not just use readfile(), include, or require instead of exec()'ing an OS command?
Copy linkTweet thisAlerts:
@acemoauthorMar 02.2006 — 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..
Copy linkTweet thisAlerts:
@acemoauthorMar 07.2006 — 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.

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

Success!

Help @acemo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...