Re: Using variable to another script

2003-02-06 Thread Randal L. Schwartz
> "James" == James Kipp <[EMAIL PROTECTED]> writes:

James> or use a hidden param in a form:

James> print qq(
James>  http://yourhost/another.cgi";>
James>  
James>  
James>  
James> );

No, no, no.  You aren't encoding it properly.  THere's already stuff
in CGI.pm to do this for you properly.

param("username", $username);
print
  start_form("http://yourhost/another.cgi";),
  hidden("username"),
  submit,
  end_form;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Cookie INfo

2003-02-06 Thread Kipp, James
> All am I am trying to do now is have a user enter his/her 
> name in a form and have that saved to a cookie, so when they 
> return, they will get something like " Your juser, please 
> proceed" . I took the example here: 
> http://stein.cshl.org/WWW/CGI/examples/cookie.cgi
> 
> Below is the code I am working with.  But when I return to 
> the page I just get the form again. What am i missing. Sorry 
> if this is obvious, but i am not getting it and I have read 
> the tutorial and the RFC on http state (thanks John ).

I revised the code to get rid of the obvious mistakes. I can see that the
cookie is made, but how can get it to print the user after it reads that
there is indeed a a cookie. 
here is what i have now:
---
use CGI qw(:standard);
# get cookie if it is there
%all = cookie('user');
# Recover the new users from the form parameter 'new_user'
$new = param('new_user'); 

# Add  the user submitted in the form as the new cookie
$cookie = cookie(-name=>'user',
 -value=>$new,
 -expires=>'+1h');

# Print the header, incorporating the cookie and the expiration date...
print header(-cookie=>$cookie);
# Now we're ready to create our HTML page.
print start_html('Test cookie');

if (%all) { # shouldn't it print if there is a cookie
found??
foreach $key ( keys %all) {
print "$all{$key}";
}
}
else { print " NO USERS SAVED " };

print qq(

User Name:  
  

);

print end_html; 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Cookie INfo

2003-02-06 Thread Kipp, James
>
 
> > Do you have a specific question? it seems:
> > 
> > http://search.cpan.org/author/LDS/CGI.pm-2.89/CGI.pm#HTTP_COOKIES 
> > 
> > Covers things pretty extensively, short of looking at the 
> > source to see how things are implemented rather than just the 
> > API.  Really very little to them.
> 

I have a real question now :)
All am I am trying to do now is have a user enter his/her name in a form and
have that saved to a cookie, so when they return, they will get something
like " Your juser, please proceed" . I took the example here:
http://stein.cshl.org/WWW/CGI/examples/cookie.cgi

Below is the code I am working with.  But when I return to the page I just
get the form again. What am i missing. Sorry if this is obvious, but i am
not getting it and I have read the tutorial and the RFC on http state
(thanks John ).

Thanks
---

use CGI qw(:standard);

# Recover  previous cookie if there is one.
%all = cookie('users');

# Recover the new users(s) from the parameter 'new_users'
@new = param('new_users'); 

# Add new animals to old, and put them in a cookie
$cookie = cookie(-name=>'users',
 -value=>\%all,
 -expires=>'+1h');

# Print the header, incorporating the cookie and the expiration date...
print header(-cookie=>$cookie);

# Now we're ready to create our HTML page.
print start_html('Test cookie');

if (%all) { # this should print the user stored in
cookie ??
foreach $key ( keys %all) {
print "$all{$key}";
}
}


print qq(

User Name 
  

);

print end_html;


 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Premature end of script headers

2003-02-06 Thread Bob Showalter
[redirected to beginners-cgi list]

zegdatwel wrote:
> hi,
> 
> "Premature end of script headers"
> 
> what can this mean...it's in the error log. When does this
> happen? I got error 500 when executing script.

It means your script ended (normally or abnormally) before emitting a proper
MIME header. The web server needs to find your response headers so it can
add some of its own before sending the full response back to the client. For
some reason, the server isn't finding the headers.

This can be caused by:

1. Your script died for some reason. If an error message was output by perl
or by your script, it should be in the web server's error log, so look
there.

2. Your script is not emitting a proper MIME header.

Lots of good information can be found at
http://www.perl.org/CGI_MetaFAQ.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Parsing a file as it is being served

2003-02-06 Thread Philip Pawley
I want to be able to adapt my web-files, as they are being served, so that older 
browsers get an xhtml 1.0-transitional version instead of the default xhtml 1.1 
version. This will involve replacing the DOCTYPE declaration and, also, various xhtml 
tags to include deprecated html attributes. This needs to happen only for older user 
agents such as Netscape 4.

I imagine this can be done using some search-and-replace module but I can't find a 
suitable one. 

Currently, I am using SSI to run a browser-detection script and insert appropriate css 
 and javascript  tags. The problem with that is that it 
limits me to parsing only a small portion of the html file. Earlier, I asked a 
question about re-using variables so that I could use the several SSI includes and 
several scripts to do the task. It seems that storing the computed values of the 
variables from one script to the next is a bit too involved. (Thanks you, Wiggins 
D'Anconia, for your help with that).

Thanks,


Philip Pawley


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Using variable to another script

2003-02-06 Thread Kipp, James

> $username = param('username');
> $lastname = param('lastname');
> 
> my question is, how can i use that two variable to another script 
> open by this command:
> 
> system('sudo', '-u', 'www', '/path/to/anotherscript.pl');
> 
> Is that possible?

You could redirect to another url:
print $q->redirect( "http://yourhost/another.cgi?username=$usernamename"; );

or use a hidden param in a form:

print qq(
http://yourhost/another.cgi";>



);


then have that script run your system() command

HTH,
Jim


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Cookie INfo

2003-02-06 Thread Kipp, James
> 
> You also might want some background on the HTTP header field 
> for Set-Cookie - sort of behind the scenes of what the CGI 
> module does.
> 
> I'd suggest some research for "RFC 2109" and "http 
> set-cookie". I found this helpful to understand the simple 
> cookie header-field syntax, separate from the CGI methods 
> syntax in it's perldoc.

Good Idea. Thanks

 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Weekly list FAQ posting

2003-02-06 Thread casey
NAME
beginners-faq - FAQ for the beginners-cgi mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners-cgi%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a month, and will be
available online in the archives, and at http://beginners.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners-cgi list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl/CGI beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners-cgi' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere. The topic of the list is, of course, CGI with Perl.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Non Perl/CGI questions or issues
* Lemurs
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl/CGI , then it is allowed. If your
question has nothing at all to do with Perl/CGI, it will likely be
ignored.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?

* Perl Home Page - http://www.perl.com
* PerlMonks - http://www.perlmonks.org
* Perldoc - http://www.perldoc.com
* Perl Archives - http://www.perlarchives.com
  3.2 - What resources may be harmful to a beginner?

Beware of Perl4-like code-- You might find some script archives and
unauthorized mirrors with old Perl4 versions of Selena Sol and Matt
Wright scripts. Don't use those scripts. They are outdated and may even
in some cases contain bugs or security problems since many may not have
been u

using variable to another script

2003-02-06 Thread Glynn S. Condez
Hi all,

I have a question. From a web form, i pass the info to a cgi script.

i have this variable on the script:

$username = param('username');
$lastname = param('lastname');

my question is, how can i use that two variable to another script 
open by this command:

system('sudo', '-u', 'www', '/path/to/anotherscript.pl');

Is that possible?

TIA
--- Glynn ---





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Using variable to another script

2003-02-06 Thread wiggins


On Thu, 6 Feb 2003 13:59:51 +0800, "Glynn S. Condez" <[EMAIL PROTECTED]> 
wrote:

> Hi all,
> 
> I have a question. From a web form, i pass the info to a cgi script.
> 
> i have this variable on the script:
> 
> $username = param('username');
> $lastname = param('lastname');
> 
> my question is, how can i use that two variable to another script 
> open by this command:
> 
> system('sudo', '-u', 'www', '/path/to/anotherscript.pl');
> 

Assuming you have worked out the details with sudo ahead of time (aka not having to 
enter a password, etc.), then:

system('sudo','-u','www',"/path/to/anotherscript.pl $username $lastname");

Should work, and 'anotherscript.pl' will have to expect the arguments in ARGV[0,1].  

If anotherscript.pl is and *must* be a cgi script, then you really have two options, 
develop it in such a way that it expects parameters in ARGV, which I believe CGI 
module will handle, or you can call a third party provider, like lynx, curl, etc. to 
call the script over HTTP but this gets harry and would seemingly lose your sudo 
privileges.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]