Script to pass info to GET string

Script to pass info to GET string

am 12.11.2004 16:59:20 von Shabam

I need to create a perl script that basically loads a web page, asks for a
Username and stores it as "Username". Also, it takes the domain name of the
site (that runs the script) and stores that in "Domain".

Next it does a substition:

http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain

And forwards the user to that url.

I'm a total newbie here. Can someone hack up a quick script based on this
requirement? I'm going to do some string limits later, but I need some
template to start with as I'm completely stuck. Thanks!

Re: Script to pass info to GET string

am 12.11.2004 17:20:50 von Paul Lalli

[removed non-existant groups, set followups to c.l.p.m]

"Shabam" wrote in message
news:hcSdnc3upp6EQAncRVn-oA@adelphia.com...
> I need to create a perl script that basically loads a web page, asks
for a

Define "loads a web page". Are you running a script that will retrieve
a webpage, or are you creating a CGI script running on some web server?

Option 1: perldoc LWP::Simple
Option 2: perldoc CGI

> Username and stores it as "Username". Also, it takes the domain name
of the
> site (that runs the script) and stores that in "Domain".
>
> Next it does a substition:

perldoc perlre

>
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain
>
> And forwards the user to that url.

perldoc LWP::Simple

> I'm a total newbie here.

http://learn.perl.org

> Can someone hack up a quick script based on this
> requirement?

http://jobs.perl.org

> I'm going to do some string limits later, but I need some
> template to start with as I'm completely stuck. Thanks!

You're quite welcome.

Paul Lalli

Re: Script to pass info to GET string

am 12.11.2004 17:20:50 von Paul Lalli

[removed non-existant groups, set followups to c.l.p.m]

"Shabam" wrote in message
news:hcSdnc3upp6EQAncRVn-oA@adelphia.com...
> I need to create a perl script that basically loads a web page, asks
for a

Define "loads a web page". Are you running a script that will retrieve
a webpage, or are you creating a CGI script running on some web server?

Option 1: perldoc LWP::Simple
Option 2: perldoc CGI

> Username and stores it as "Username". Also, it takes the domain name
of the
> site (that runs the script) and stores that in "Domain".
>
> Next it does a substition:

perldoc perlre

>
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain
>
> And forwards the user to that url.

perldoc LWP::Simple

> I'm a total newbie here.

http://learn.perl.org

> Can someone hack up a quick script based on this
> requirement?

http://jobs.perl.org

> I'm going to do some string limits later, but I need some
> template to start with as I'm completely stuck. Thanks!

You're quite welcome.

Paul Lalli

Re: Script to pass info to GET string

am 12.11.2004 18:01:29 von jurgenex

Shabam wrote:
> I need to create a perl script that basically loads a web page,

perldoc LWP

> asks
> for a Username

perldoc -f print
perldoc perlop (pretty far down in the section about "I/O Operators")

> and stores it as "Username". Also, it takes the

Now, where and how do you want to store that? In a file? In a database? What
kind of database? Just not enough information...

> domain name of the site (that runs the script) and stores that in
> "Domain".
>
> Next it does a substition:
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain

I suppose this is meant to be result of the substitution? What is the
original string? Not enough information...

> And forwards the user to that url.

???
Do you mean you want to open a browser program and load that page?
perldoc -f system
perldoc -f exec

> I'm a total newbie here. Can someone hack up a quick script based on
> this requirement?

Can probably yes, want to unlikely.
If you are looking for ready-made scripts you came to the wrong place.
Show us what you have and many people here will be happy to help you with
the next step.

jue

Re: Script to pass info to GET string

am 12.11.2004 18:01:29 von jurgenex

Shabam wrote:
> I need to create a perl script that basically loads a web page,

perldoc LWP

> asks
> for a Username

perldoc -f print
perldoc perlop (pretty far down in the section about "I/O Operators")

> and stores it as "Username". Also, it takes the

Now, where and how do you want to store that? In a file? In a database? What
kind of database? Just not enough information...

> domain name of the site (that runs the script) and stores that in
> "Domain".
>
> Next it does a substition:
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain

I suppose this is meant to be result of the substitution? What is the
original string? Not enough information...

> And forwards the user to that url.

???
Do you mean you want to open a browser program and load that page?
perldoc -f system
perldoc -f exec

> I'm a total newbie here. Can someone hack up a quick script based on
> this requirement?

Can probably yes, want to unlikely.
If you are looking for ready-made scripts you came to the wrong place.
Show us what you have and many people here will be happy to help you with
the next step.

jue

Re: Script to pass info to GET string

am 12.11.2004 18:11:12 von Shabam

> Now, where and how do you want to store that? In a file? In a database?
What
> kind of database? Just not enough information...

Very basic. Just in memory is fine.

> > domain name of the site (that runs the script) and stores that in
> > "Domain".
> >
> > Next it does a substition:
> > http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain
>
> I suppose this is meant to be result of the substitution? What is the
> original string? Not enough information...

I just need it to substitute the "Username" and "Domain" into the string,
and redirect the user to that url. The
"http://www.anothersite.com/whatever.cgi" part of it is hardcoded.

> Do you mean you want to open a browser program and load that page?
> perldoc -f system
> perldoc -f exec

No. I mean this whole script is running as a cgi on a web page. It takes
the username that the user enters, and based on the domain name that the cgi
script is running from, gets the other variable (Domain). Then, it
redirects the user to the url
http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain.

Re: Script to pass info to GET string

am 12.11.2004 18:11:12 von Shabam

> Now, where and how do you want to store that? In a file? In a database?
What
> kind of database? Just not enough information...

Very basic. Just in memory is fine.

> > domain name of the site (that runs the script) and stores that in
> > "Domain".
> >
> > Next it does a substition:
> > http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain
>
> I suppose this is meant to be result of the substitution? What is the
> original string? Not enough information...

I just need it to substitute the "Username" and "Domain" into the string,
and redirect the user to that url. The
"http://www.anothersite.com/whatever.cgi" part of it is hardcoded.

> Do you mean you want to open a browser program and load that page?
> perldoc -f system
> perldoc -f exec

No. I mean this whole script is running as a cgi on a web page. It takes
the username that the user enters, and based on the domain name that the cgi
script is running from, gets the other variable (Domain). Then, it
redirects the user to the url
http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain.

Re: Script to pass info to GET string

am 12.11.2004 18:15:29 von jurgenex

Shabam wrote:
[...]
> No. I mean this whole script is running as a cgi on a web page.

Oh, a stealth CGI question.
Good by then.


jue

Re: Script to pass info to GET string

am 12.11.2004 18:15:29 von jurgenex

Shabam wrote:
[...]
> No. I mean this whole script is running as a cgi on a web page.

Oh, a stealth CGI question.
Good by then.


jue

Re: Script to pass info to GET string

am 12.11.2004 18:56:34 von Shabam

> Oh, a stealth CGI question.
> Good by then.

What are you talking about? It's a simple web page cgi. User enters
"Username", and the page takes that, along with the domain name from the
server, and redirects the user to another script. This is being used for an
order system for hosting, so that the user gets http://username.domain.com
as their address. The billing system I'm using now doesn't support such a
mechanism natively, as it accepts full domain names only. Thus I need to do
it this way.

I'm guessing you think I'm trying to do something bad. Don't assume,
without any basis.

Re: Script to pass info to GET string

am 12.11.2004 18:56:34 von Shabam

> Oh, a stealth CGI question.
> Good by then.

What are you talking about? It's a simple web page cgi. User enters
"Username", and the page takes that, along with the domain name from the
server, and redirects the user to another script. This is being used for an
order system for hosting, so that the user gets http://username.domain.com
as their address. The billing system I'm using now doesn't support such a
mechanism natively, as it accepts full domain names only. Thus I need to do
it this way.

I'm guessing you think I'm trying to do something bad. Don't assume,
without any basis.

Re: Script to pass info to GET string

am 12.11.2004 20:47:19 von Ben Morrow

[newsgroups trimmed]

Quoth "Shabam" :
> > Oh, a stealth CGI question.
> > Good by then.
>
> What are you talking about? It's a simple web page cgi. User enters
> "Username", and the page takes that, along with the domain name from the
> server, and redirects the user to another script. This is being used for an
> order system for hosting, so that the user gets http://username.domain.com
> as their address. The billing system I'm using now doesn't support such a
> mechanism natively, as it accepts full domain names only. Thus I need to do
> it this way.
>
> I'm guessing you think I'm trying to do something bad. Don't assume,
> without any basis.

LOL!

No, he meant that your question was actually about CGI, but you didn't
say so. Questions like that are not welcome here: we get too many of
them, and they're not interesting.

Ben

--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'

Re: Script to pass info to GET string

am 12.11.2004 20:47:19 von Ben Morrow

[newsgroups trimmed]

Quoth "Shabam" :
> > Oh, a stealth CGI question.
> > Good by then.
>
> What are you talking about? It's a simple web page cgi. User enters
> "Username", and the page takes that, along with the domain name from the
> server, and redirects the user to another script. This is being used for an
> order system for hosting, so that the user gets http://username.domain.com
> as their address. The billing system I'm using now doesn't support such a
> mechanism natively, as it accepts full domain names only. Thus I need to do
> it this way.
>
> I'm guessing you think I'm trying to do something bad. Don't assume,
> without any basis.

LOL!

No, he meant that your question was actually about CGI, but you didn't
say so. Questions like that are not welcome here: we get too many of
them, and they're not interesting.

Ben

--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'

Re: Script to pass info to GET string

am 12.11.2004 20:53:51 von dha

On 2004-11-12, Shabam wrote:
>> Oh, a stealth CGI question.
>> Good by then.
>
> What are you talking about? It's a simple web page cgi.
[snip]
> I'm guessing you think I'm trying to do something bad. Don't assume,
> without any basis.

I think the only bad thing he thinks you may be doing is asking a
question about CGI in a Perl newsgroup. Contrary to unfortunately
popular belief, CGI and Perl are not the same thing. CGI is an
interface, programs for which can be written in various languages
(including) Perl. If your question would be no different if you were
programming in, for instance, C, you probably want to look at a group
that has cgi in its name instead.

dha

--
David H. Adler - - http://www.panix.com/~dha/
Nice DNS error you have there.
- subbes

Re: Script to pass info to GET string

am 12.11.2004 20:53:51 von dha

On 2004-11-12, Shabam wrote:
>> Oh, a stealth CGI question.
>> Good by then.
>
> What are you talking about? It's a simple web page cgi.
[snip]
> I'm guessing you think I'm trying to do something bad. Don't assume,
> without any basis.

I think the only bad thing he thinks you may be doing is asking a
question about CGI in a Perl newsgroup. Contrary to unfortunately
popular belief, CGI and Perl are not the same thing. CGI is an
interface, programs for which can be written in various languages
(including) Perl. If your question would be no different if you were
programming in, for instance, C, you probably want to look at a group
that has cgi in its name instead.

dha

--
David H. Adler - - http://www.panix.com/~dha/
Nice DNS error you have there.
- subbes

Re: Script to pass info to GET string

am 14.11.2004 09:44:54 von Joe Smith

Shabam wrote:

> No. I mean this whole script is running as a cgi on a web page. It takes
> the username that the user enters, and based on the domain name that the cgi
> script is running from, gets the other variable (Domain). Then, it
> redirects the user to the url
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain.

my $server_host = $ENV{HTTP_HOST};
(my $domain = $server_host) =~ s/^www\.//'; # Gross assumption
my $username = some basic CGI processing here.
print "$redirect_url?var1=$username;var2=$domain";

For the 'some basic CGI processing here', you should go ask in
one of the CGI newsgroups, as the solution is not perl-specific.

-Joe

Re: Script to pass info to GET string

am 14.11.2004 09:44:54 von Joe Smith

Shabam wrote:

> No. I mean this whole script is running as a cgi on a web page. It takes
> the username that the user enters, and based on the domain name that the cgi
> script is running from, gets the other variable (Domain). Then, it
> redirects the user to the url
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=D omain.

my $server_host = $ENV{HTTP_HOST};
(my $domain = $server_host) =~ s/^www\.//'; # Gross assumption
my $username = some basic CGI processing here.
print "$redirect_url?var1=$username;var2=$domain";

For the 'some basic CGI processing here', you should go ask in
one of the CGI newsgroups, as the solution is not perl-specific.

-Joe

Re: Script to pass info to GET string

am 14.11.2004 09:54:42 von Joe Smith

Shabam wrote:

>>Oh, a stealth CGI question.
>
> I'm guessing you think I'm trying to do something bad.

Not at all. We think you're asking a basic CGI question
in a perl language newsgroup instead of in a CGI-oriented
newsgroup. That's what 'stealth CGI question' means.

We're here to help, after you've written some perl code.
You'll find that these newsgroups are not the place to go
for a beginner's guide to CGI programming.
-Joe

Re: Script to pass info to GET string

am 14.11.2004 09:54:42 von Joe Smith

Shabam wrote:

>>Oh, a stealth CGI question.
>
> I'm guessing you think I'm trying to do something bad.

Not at all. We think you're asking a basic CGI question
in a perl language newsgroup instead of in a CGI-oriented
newsgroup. That's what 'stealth CGI question' means.

We're here to help, after you've written some perl code.
You'll find that these newsgroups are not the place to go
for a beginner's guide to CGI programming.
-Joe

Re: Script to pass info to GET string

am 14.11.2004 20:12:03 von webmaster

In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
Ben Morrow wrote:

> No, he meant that your question was actually about CGI, but you didn't
> say so. Questions like that are not welcome here: we get too many of
> them, and they're not interesting.

1. If the script is written in Perl, why should it not be welcome on a Perl
newsgroup?

2. However, if it really is not welcome, where should people with Perl cgi
scripts go?

Ken Down

--
================ ARCHAEOLOGICAL DIGGINGS ===============
| Australia's premiere archaeological magazine |
| http://www.diggingsonline.com |
========================================================

Re: Script to pass info to GET string

am 14.11.2004 20:12:03 von webmaster

In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
Ben Morrow wrote:

> No, he meant that your question was actually about CGI, but you didn't
> say so. Questions like that are not welcome here: we get too many of
> them, and they're not interesting.

1. If the script is written in Perl, why should it not be welcome on a Perl
newsgroup?

2. However, if it really is not welcome, where should people with Perl cgi
scripts go?

Ken Down

--
================ ARCHAEOLOGICAL DIGGINGS ===============
| Australia's premiere archaeological magazine |
| http://www.diggingsonline.com |
========================================================

Re: Script to pass info to GET string

am 15.11.2004 12:03:01 von jurgenex

Kendall K. Down wrote:
> In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
> Ben Morrow wrote:
>
>> No, he meant that your question was actually about CGI, but you
>> didn't say so. Questions like that are not welcome here: we get too
>> many of them, and they're not interesting.
>
> 1. If the script is written in Perl, why should it not be welcome on
> a Perl newsgroup?
>
> 2. However, if it really is not welcome, where should people with
> Perl cgi scripts go?

If the question is about Perl or perl then ask here.
If the question is about CGI then ask in a CGI NG (see "perldoc -q 500").
If the question is about HTML then ask in a HMTL NG.

jue

Re: Script to pass info to GET string

am 15.11.2004 12:03:02 von jurgenex

Kendall K. Down wrote:
> In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
> Ben Morrow wrote:
>
>> No, he meant that your question was actually about CGI, but you
>> didn't say so. Questions like that are not welcome here: we get too
>> many of them, and they're not interesting.
>
> 1. If the script is written in Perl, why should it not be welcome on
> a Perl newsgroup?
>
> 2. However, if it really is not welcome, where should people with
> Perl cgi scripts go?

If the question is about Perl or perl then ask here.
If the question is about CGI then ask in a CGI NG (see "perldoc -q 500").
If the question is about HTML then ask in a HMTL NG.

jue

Re: Script to pass info to GET string

am 15.11.2004 13:56:28 von flavell

On Sun, 14 Nov 2004, Kendall K. Down wrote:

> 1. If the script is written in Perl, why should it not be welcome on a Perl
> newsgroup?

Most programmers need coffee, so why not discuss all programming
questions on a coffee newsgroup ? Hence or otherwise deduce...

Re: Script to pass info to GET string

am 15.11.2004 13:56:28 von flavell

On Sun, 14 Nov 2004, Kendall K. Down wrote:

> 1. If the script is written in Perl, why should it not be welcome on a Perl
> newsgroup?

Most programmers need coffee, so why not discuss all programming
questions on a coffee newsgroup ? Hence or otherwise deduce...

Re: Script to pass info to GET string

am 15.11.2004 16:08:52 von Tad McClellan

[ Newsgroups trimmed. ]


Kendall K Down wrote:
> In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
> Ben Morrow wrote:
>
>> No, he meant that your question was actually about CGI, but you didn't
>> say so. Questions like that are not welcome here: we get too many of
>> them, and they're not interesting.
>
> 1. If the script is written in Perl,


The criteria is not what language you are using, the criteria is
what your question is about.

Your question was basically:

How do I do a redirect?

(Which is a Perl Frequently Asked Question BTW.)

If you were using Java instead of Perl, your question would have been:

How do I do a redirect?

ie. the question is independent of the programming language being used.

The answer is:

Output the appropriate Location header.

without regard to which programming language you've chosen to use.



Step 1 is knowing what output you want to make.

Step 2 is knowing how to make that output with your language of choice.


> why should it not be welcome on a Perl
> newsgroup?


The answer to the "Step 2" part of your question is:

You use the print() function to make output.


> 2. However, if it really is not welcome, where should people with Perl cgi
> scripts go?


That depends on what their question is about.

If it is about Perl, then ask here.

If it is about the CGI, then ask in a CGI newsgroup.


(there is a mailing list specificaly for using Perl in a CGI
environment, see http://lists.perl.org.
)


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Re: Script to pass info to GET string

am 15.11.2004 19:41:57 von Henry Law

On Mon, 15 Nov 2004 09:08:52 -0600, Tad McClellan
wrote:

>The criteria is not what language you are using,
on
--

Henry Law <>< Manchester, England