PHP/Perl/ASP to Server

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

Hello
I'm not really sure if this is possible but...
Is there a way to start/end processes or even restart a server from PHP, Perl, or ASP?
Help me out here if you can...
Thanks

Laughing out loud

They have: 601 posts

Joined: Nov 2001

Yes. Anything (well, nearly) is possible with Perl. Probably is with PHP or ASP too, but I have limited knoweldge of these languages.

What exactly do you want to do?

The easy way to kill a process would be:

my $pid
system ("kill -HUP $pid");

The _biggest_ problems you will face is permissions. You will most likely need to be root to restart/shut down your web server. This could prove tricky using any programming language, as the web server usually treats users as user nobody.

This is assuming you're trying to do this from a web browser, of course?

- wil

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

You can do the same thing with ASP/IIS, but you'll need to have the permissions set correctly.

To stop/start a website:

set IISOBJ = getObject("IIS://localhost/w3svc/1")
IISOBJ.Stop
set IISOBJ = nothing

Just replace Stop with Start to start it. The 1 refers to the instanceID of the website.

PJ | Are we there yet?
pjboettcher.com

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

I think I'll be using perl or PHP....
What permissions need to be set?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.