Jump to content

[SOLVED] Command Line Only


Rednarb

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.