For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > November 2004 > Script to pass info to GET string









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 Script to pass info to GET string
Shabam

2004-11-12, 3:55 pm

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...ame&var2=Domain

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!


Paul Lalli

2004-11-12, 3:55 pm

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

"Shabam" <blislecp@hotmail.com> 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...ame&var2=Domain
>
> 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

Jürgen Exner

2004-11-12, 3:55 pm

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...ame&var2=Domain


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


Shabam

2004-11-12, 3:55 pm

> 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.

>
> 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...me&var2=Domain.



Jürgen Exner

2004-11-12, 3:55 pm

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


Shabam

2004-11-12, 3:55 pm

> 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.


David H. Adler

2004-11-12, 8:55 pm

On 2004-11-12, Shabam <blislecp@hotmail.com> wrote:
>
> 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 - <dha@panix.com> - http://www.panix.com/~dha/
Nice DNS error you have there.
- subbes
Joe Smith

2004-11-14, 8:55 am

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...me&var2=Domain.


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
Joe Smith

2004-11-14, 8:55 am

Shabam wrote:

>
> 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
Ben Morrow

2004-11-14, 3:55 pm

[newsgroups trimmed]

Quoth "Shabam" <blislecp@hotmail.com>:
>
> 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'
Kendall K. Down

2004-11-15, 3:55 am

In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
Ben Morrow <usenet@morrow.me.uk> 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 |
========================================
================
Jürgen Exner

2004-11-15, 8:55 am

Kendall K. Down wrote:
> In message <7jgf62-mh5.ln1@osiris.mauzo.dyndns.org>
> Ben Morrow <usenet@morrow.me.uk> wrote:
>
>
> 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


Alan J. Flavell

2004-11-15, 3:55 pm

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...
Sponsored Links







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

Copyright 2008 codecomments.com