Using system() like an http "get"

B

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&param2=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&param2=2");

Bill
 
P

Paul Lalli

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&param2=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&param2=2");

No. system() executes a program specified on the command line.
Unless "scriptname.pl?param1=1&param2=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&param2=2");

Paul Lalli
 
A

all mail refused

scriptname.pl?param1=1&param2=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&param2=2");

I'm afraid Hotspur and Glendower got to this one first.
http://www.alanhoward.org.uk/spell.htm
What's the shell produced by system() going to think when it sees "&",
and does "scriptname.pl?param1=1" match anything in the PATH ?
 
B

Bill H

No. system() executes a program specified on the command line.
Unless "scriptname.pl?param1=1&param2=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&param2=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
 
D

Doug Miller

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&param2=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&param2=2");

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

env -i QUERY_STRING="param1=1&param2=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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top