/    Sign up×
Community /Pin to ProfileBookmark

Proc_open(sc) Windows

Morning. Im trying to check the state of a service on distant machine, currently im using exec but if machine is unreachable exec sc tries to connect to service forever, without the idea on how to put timeout on exec i found proc_open proc_terminate combination but im having a hard time making it run. I copied the code twiked it a bit but i still have no idea of whats happening with this code. What i want is to run SC and get the result as php variable, in worst case get the output of SC into a file. Currently i have no idea how to make it work the code bellow doesnt write anything to error.txt

[code=php]$descriptorspec = array(
0 => array(“pipe”, “r”),
1 => array(“pipe”, “w”),
2 => array(“file”, “lerror.txt”, “a”) );
// Create child and start process
$child = array(“process” => null, “pipes” => null);
$child[“process”] = proc_open(“sc \999.999.999.999 query Spooler”, $descriptorspec, $child[“pipes”]);[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Stobor 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...