run script from shell and make it work..

hello there,
i am trying to run and make this little script from the linux shell but for some reason is always saying (no name)
how can I make it work and run?
if (isset($_REQUEST['name']) == 'bob') {
	echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
else
	echo 'no name provided';

Open in new window

LVL 1
XK8ERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

svgmucCommented:
$_POST is only populated when run through a web-server. The variable is empty or non-existent when you run the script from shell.
0
HackneyCabCommented:
If you're running scripts from the command line, you want the following predefined variables instead of $_REQUEST,

$_SERVER['argc']    the number of parameters passed to the script on the command line

$_SERVER['argv']    an array of parameters passed to the script

So you should be able to change $_REQUEST['name'] to $_SERVER['argv'][0] (assuming the name value is the first parameter passed to the script).

See the relevant page in the PHP manual: http://www.php.net/manual/en/reserved.variables.server.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.