For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > January 2006 > difference web/cli









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author difference web/cli
Brano Gerzo

2006-01-10, 3:56 am

Hi all,

I am programming one script. It should be accessible as cgi-bin from
web, and also as commandline from shell.

But I don't know how to properly handle arguments and to know, if script
was called from commandline, or from web.

Anyone could help me ?

Thanks.

Chris Devers

2006-01-10, 3:56 am

On Tue, 27 Dec 2005, Brano Gerzo wrote:

> I am programming one script. It should be accessible as cgi-bin from
> web, and also as commandline from shell.
>
> But I don't know how to properly handle arguments and to know, if
> script was called from commandline, or from web.
>
> Anyone could help me ?


Probably.

Are you examining the %ENV hash ?

It will have hints as to how the script was invoked.


--
Chris Devers
Shawn Corey

2006-01-10, 3:56 am

Chris Devers wrote:
> On Tue, 27 Dec 2005, Brano Gerzo wrote:
>
>
> Probably.
>
> Are you examining the %ENV hash ?
>
> It will have hints as to how the script was invoked.
>
>


If the script is called via the web server, it probably does not have
any arguments. It could also be invoked from different users. See
`perldoc perlvar` and search for '$<' and '$>'.


--

Just my 0.00000002 million dollars worth,
--- Shawn

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

* Always write your code as though you aren't going to see it
* for another 25 years and then one day your boss comes up to you
* and says, "I want these changes and I want them yesterday!"

"Probability is now one. Any problems that are left are your own."
SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

Brano Gerzo

2006-01-10, 3:56 am

Shawn Corey [SC], on Tuesday, December 27, 2005 at 19:44 (-0500) has
on mind:

SC> If the script is called via the web server, it probably does not have
SC> any arguments. It could also be invoked from different users. See
SC> `perldoc perlvar` and search for '$<' and '$>'.

thanks for idea, arguments checking is not good idea I think (I did it
so), but user check is a bit better. Also %ENV is OK.

Thanks to all.

--

...m8s, cu l8r, Brano.

[Cannot open file "18: RIME direct routing is easy! Ask your Conference
Host about it."]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com