Jump to content

Recommended Posts

WHAT?

do you mean you want php to run in command line for users to use the application but running in command line only........

 

 

are you talking about creating a shell program with php and users got to telnet to use the shell program?

 

example an old bulition board

Check for $_SERVER['SHELL']

 

This is not set via browser, only via shell.

 

Also, none of the $_SERVER['HTTP_***'] values are set when run via the console either. Don't rely on those though.

 

$_SERVER['SHELL'] should be checked for a value (/bin/bash or whatever the default shell is). if it's set, you're good.

WHAT?

do you mean you want php to run in command line for users to use the application but running in command line only........

 

 

are you talking about creating a shell program with php and users got to telnet to use the shell program?

 

example an old bulition board

 

No no, not so devious as that!

 

I simply have a php script that does some daily reporting that I want to run, and without going into too much detail as to why, its in a location where it could be accessible from a browser. This is all internal use, not on the Internet, so I'm not too concerned with security.. but just in case someone (like another administrator after I get hit by a bus) tries to run the .php from a browser then the script dies saying it can't run that way.

 

I recall seeing a way to do it a long time ago... I think it checked some sort of $_SERVER variable and if it equaled ~something~ that meant it was the web service or a browser running it then it would die. I don't want to reinvent the wheel but I can't seem to find it anywhere so I thought I'd post here for suggestions.

Check for $_SERVER['SHELL']

 

This is not set via browser, only via shell.

 

Also, none of the $_SERVER['HTTP_***'] values are set when run via the console either. Don't rely on those though.

 

$_SERVER['SHELL'] should be checked for a value (/bin/bash or whatever the default shell is). if it's set, you're good.

 

Exactly what I needed! THANKS!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.