Using system() like an http "get"

Using system() like an http "get"

am 11.10.2007 19:02:12 von Bill H

I have a number of pages on a website that run perl scripts to create
different content. They are all basically accessed with an HREF such
as:

scriptname.pl?param1=1¶m2=2 etc

The question I have is, an I use the same syntax in a system call from
another perl program, ie:

system("scriptname.pl?param1=1¶m2=2");

Bill

Re: Using system() like an http "get"

am 11.10.2007 19:06:06 von Paul Lalli

On Oct 11, 1:02 pm, Bill H wrote:
> I have a number of pages on a website that run perl scripts to
> create different content. They are all basically accessed with
> an HREF such as:
>
> scriptname.pl?param1=1¶m2=2 etc
>
> The question I have is, an I use the same syntax in a system
> call from another perl program, ie:
>
> system("scriptname.pl?param1=1¶m2=2");

No. system() executes a program specified on the command line.
Unless "scriptname.pl?param1=1¶m2=2" is a valid command you could
type at your console window, you can't use system() for it.

You want LWP::Simple, and it's "get" method:

use LWP::Simple;
my $content = get("http://www.example.com/scriptname.pl?
param1=1¶m2=2");

Paul Lalli

Re: Using system() like an http "get"

am 11.10.2007 19:15:41 von unknown

Post removed (X-No-Archive: yes)

Re: Using system() like an http "get"

am 11.10.2007 19:19:54 von Bill H

On Oct 11, 1:06 pm, Paul Lalli wrote:
> On Oct 11, 1:02 pm, Bill H wrote:
>
> > I have a number of pages on a website that run perl scripts to
> > create different content. They are all basically accessed with
> > an HREF such as:
>
> > scriptname.pl?param1=1¶m2=2 etc
>
> > The question I have is, an I use the same syntax in a system
> > call from another perl program, ie:
>
> > system("scriptname.pl?param1=1¶m2=2");
>
> No. system() executes a program specified on the command line.
> Unless "scriptname.pl?param1=1¶m2=2" is a valid command you could
> type at your console window, you can't use system() for it.
>
> You want LWP::Simple, and it's "get" method:
>
> use LWP::Simple;
> my $content = get("http://www.example.com/scriptname.pl?
> param1=1¶m2=2");
>
> Paul Lalli

Thats what I realized after I posted the message. But thinking about
it, since the script I want to call is on the same server and in the
same directory I should be able to modify the ENV{'QUERY_STRING'} to
contain the new data then if I use system on the other script it
"should" work the same as if I called it from an HREF, or am I really
missing something here?

Bill H

Re: Using system() like an http "get"

am 11.10.2007 19:37:13 von spambait

In article <1192122132.151687.76860@g4g2000hsf.googlegroups.com>, Bill H wrote:
>I have a number of pages on a website that run perl scripts to create
>different content. They are all basically accessed with an HREF such
>as:
>
>scriptname.pl?param1=1¶m2=2 etc
>
>The question I have is, an I use the same syntax in a system call from
>another perl program, ie:

Probably...
>
>system("scriptname.pl?param1=1¶m2=2");

... but not like that. On my web server (Sun Solaris), this works at the
command line:

env -i QUERY_STRING="param1=1¶m2=2" /path/scriptname.pl

and presumably would work in a system() call as well, although I have not
tested it. Similar behavior would be expected under other flavors of Unix.

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.

Re: Using system() like an http "get"

am 11.10.2007 21:00:41 von Glenn Jackman

At 2007-10-11 01:02PM, "Bill H" wrote:
> I have a number of pages on a website that run perl scripts to create
> different content. They are all basically accessed with an HREF such
> as:
>
> scriptname.pl?param1=1¶m2=2 etc
>
> The question I have is, an I use the same syntax in a system call from
> another perl program, ie:
>
> system("scriptname.pl?param1=1¶m2=2");

If your scripts use CGI, you might be able to get away with this:

system("scriptname.pl param1=1 param2=2");

See http://perldoc.perl.org/CGI.html#DEBUGGING

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry