RE: cgi script that takes in data then runs script on different host

2002-05-28 Thread David Gray

First of all, don't cross-post please. One list is quite sufficient, and
many people are subscribed to more than one list, so duplicate messages
are quite often completely ignored.

 I've got a cgi form that takes in data.  Then, I want the 
 data to be passed to a script that's waiting on a DIFFERENT host.
 
 So, say I have this pseudo-code:
 
 cgi script on host 1pass $name to host 2  script on host 2
 # get $name ---  print 
 hi there $name!\n;

Could you pass $name in the query string? Like this:

 --script 1--
 #!/usr/bin/perl -w
 use strict;
 use CGI;
 my $cgi = new CGI;

 my %F = ();
 # get all values passed to this script
 # assuming no multi-valued form elements
 $F{$_} = $cgi-param($_) for $cgi-param();

 # rebuild the query string to stick on the
 # end of whatever script you want to send
 # these values to
 my $query_string = '?';
 $query_string .= $_=$F{$_}\ for keys %F;

 my $host2 = 'http://www.host2.com/script.cgi';
 print Location:$host2$query_string\n\n;
 --end script 1--


 --script 2--
 #!/usr/bin/perl -w
 use strict;
 use CGI;
 my $cgi = new CGI;

 my %F = ();
 # get all values passed to this script
 # assuming no multi-valued form elements
 $F{$_} = $cgi-param($_) for $cgi-param();

 # print them to make sure they're there
 print 'pre';
 print \$F{$_} == $F{$_}\n for keys %F;
 print '/pre';

 # do stuff with the values passed to the first script
 --end script 2--

HTH,

 -dave



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




RE: Can someone Help me out with this

2002-05-24 Thread David Gray

 Problem:
 ci_cmd1=abcdef,  // line1
 ci_cmd2=ghijk, // line2
 ci_cmd3=lmnop,   // line3
 ci_cmd4=pqrst, // line4
 
 I want to delete line 1 and 2 and the above should look like 
 as shown below:
 
 ci_cmd1=lmnop,
 ci_cmd2=pqrst,

Where are these lines? Are they in a file? Are they in a variable? Can
you post some code that you've tried?

Cheers,

 -dave


 Regards.,
 Avi

Like Avi from Snatch? =P
Got anything to declare?
Yeah, don't go to England.



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




Can someone Help me out with this

2002-05-24 Thread David Gray

you should try this.
$old=abcdef;
$new=lmnop;
$ci_cmd1 = s/$old/$new/;#this substitutes the old value with the
new one.

regards,
Ian



David Gray wrote:

  Problem:
  ci_cmd1=abcdef,  // line1
  ci_cmd2=ghijk, // line2
  ci_cmd3=lmnop,   // line3
  ci_cmd4=pqrst, // line4
 
  I want to delete line 1 and 2 and the above should look like as 
  shown below:
 
  ci_cmd1=lmnop,
  ci_cmd2=pqrst,

 Where are these lines? Are they in a file? Are they in a variable? Can

 you post some code that you've tried?

 Cheers,

  -dave

  Regards.,
  Avi

 Like Avi from Snatch? =P
 Got anything to declare?
 Yeah, don't go to England.

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




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




RE: regular expression

2002-05-17 Thread David Gray

 code  

 for(@text) {
   /(d+)$/; # Match only the numbers at the end of the string
 ^^
  this should actually be (\d+)

I would actually conditionally print also, like so:

 print $1 if /(\d+)$/;

And depending on the size of the file, instead of reading the whole
thing into memory with

 my @text = (FILE);

I would do:

 while(FILE) {
   print $1 if /(\d+)$/;
 }

# and store them in '$1' to be printed out on the
# next line followed by a new line character

  @text # contains values of a phone directory
  $text[0] contains john=012345678
  
  $phone1 = ?
  
  let say i wanted to grab just the values'012345678'.
  how should i go on truncating the values?

Cheers,

 -dave



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




RE: pass values to another scipt

2002-05-14 Thread David Gray

 Hi Sven,
 
 Sorry, I thought you knew that one.
 
 But how to proceed if you don't want those ugly/insecure 
 params in your location bar ?

Use a form and an input type=image

HTH,

 -dave



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




RE: CGI and frames

2002-05-14 Thread David Gray

 Sorry, I chose the wrong words..
 my script works similar to the way you described below. Depending on 
 which fields are filled out and which button is pressed, a different 
 subroutine is called, creating the page.

Ok... Could you post some code or pseudocode that describes the problem
you're trying to solve?

 -dave



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




RE: a href Vs Form post

2002-05-06 Thread David Gray

 I am strugling with my program that list the contents of a 
 directory. Ones the directory contains files and you have 
 permission it shows you a doc icon else it will show a 
 directory-map followed by it's name as an a href
 
 The problem I have now is that using the a href command 
 will have to show all important variables in the browsers 
 Location. Of course, you would say. But is there a nice 
 possibility to keep using the a href statement without 
 defining the variables in the href, So I can work with the :
 
 use CGI qw(:standard);
 $userid = param(userid);
 ...
 
 
 And get the variables without all users seeing what I need ?
 
 Using the input type=submit, always generates a button, (I 
 believe), that is what I don't like to have, 20 dirs, with 20 
 different submit buttons. Does anyone have an idea ?

Maybe you could use one big form and have a checkbox by each directory
instead of having twenty forms.

 Many Thanks in advance !!!
 
 Location example: 
 http://stage-www/cgi-bin/david/index.cgi?base=/user/web/apache
/stage/htdocs/david/IPlab?header=IPlab?pwuser=gaard?group=icgrp

That URL won't work for us because we're not local to your network...
Could you post some code?

 -dave



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




RE: exiting correctly

2002-04-24 Thread David Gray

 below is a snipet of the code.  the most relavant part.  when 
 i enter some bad data in or mysql has problems, it should go 
 to error_handler()  at the bottom of my script.  well it 
 does, then it returns unless i put an exit at the end of 
 error_handler.

How about:

mysub('param1','param2');
mysub('parma1','param2');

sub mysub {
  my ($p1,$p2) = @_;
  print in mysub\n;
  $p1 eq 'param1' or err_h(invalid param: [$p1]\n) or return 0;
  print passed: [$p1] [$p2]\n;
}

sub err_h {
  print $_[0] and return 0;
}

HTH,

 -dave



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




RE: asp from perl

2002-04-08 Thread David Gray

 hello everyone,i am trying to execute an asp script from a 
 perl cgi and i have the following problem
 
 I am  using something like this to get user's input and the 
 pass it to the asp
 
 ReadParse (*input);
 
 my $pin;
 my $passwd;
 
 my @input;
 
 $pin = $input {'pin'};
 
 $passwd = $input {'passwd'};
 
 my $page_url = 10.0.0.4/Validation.asp?pin=$pinpasswd=$passwd;
 
 the problem that i seem to be having is that i can not get 
 the values passed to the asp in the form of  
 variables,because the values of $pin and $passwd are no 
 actually being passed to the asp..,therefore it gives  back 
 an empty answer Does anoyone knows  how to pass the actual 
 variables values to the asp?

Check out the cgi module:

perldoc cgi

You're gonna want to do something like:

use CGI;
my $cgi = new CGI;
for($cgi-param()) {
  $F{$_} = $cgi-param($_);
}

Watch out for multivalued form inputs though. This is covered in the
CGI.pm documentation.

Hope that helps a bit,

 -dave



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




RE: Read in from STDIN

2002-04-04 Thread David Gray

 Could anyone help I am having trouble reading in information 
 from STDIN
 
 For coding see attached file
 
 Using a while loop I want to do the following:
 Read info in from STDIN
 Read in any number of name/value pairs,
 Read in names in pairs of two, and compute their sum.
 Choose the maximum of all those pairs and print it.
 At the same time choose the minimum and print it.

Your code looks fine to me - what exactly is going wrong? How are you
giving the data to STDIN (you do know that you have to hit enter each
time you want STDIN to read what you've typed, right?)?

 -dave



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




RE: Internal server error

2002-04-04 Thread David Gray

 I'm having problems with the old Internal Server Error 
 issue. I know that this is generally due to permissions. I 
 have used chmod go+rx -R *, but no joy. The html now works 
 but not the cgi. Thoughts?

Try inserting the line

use CGI::Carp (fatalsToBrowser);

At the beginning of your script. And try running it from the command
line.

Hope that helps,

 -dave



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




RE: IP Address

2002-04-04 Thread David Gray

  David == David Gray [EMAIL PROTECTED] writes:
 
  How do I get the IP address from a POST form.
  
  Let me make myself more clear: I have a form that uses POST,
  and I would like to get users' IP address for avoiding the 
  same user to fake my pool's result.
 
 David You can check $ENV{REMOTE_ADDR}, which will contain 
 the remote IP 
 David of the user hitting your page.
 
 And that's still insufficient and incorrect.
 
 Repeat after me:
 
 A user is not an IP address
 A user is not an IP address
 A user is not an IP address
 
 Specifically, the largest userbase on the planet, AOL, comes 
 into the Internet proper via Web Proxies.  On every hit, a 
 different proxy is used, so these hits show up as coming from 
 completely different addresses.  Even the main page and the 
 image fetches for that page will all show up as different 
 addresses.  And then of course, those same 
 small-number-of-proxies are used for millions of users.
 
 So again, I repeat:
 
 A user is not an IP address
 
 Get it through your head that using IP address for vote 
 blockout is just ... WRONG.

Message received, ZERO distortion. Are you saying, then, that it's
impossible to build an accessible cgi-based voting system (which allows
more than one user to access the system from within a large network)
without using cookies or forcing each user to log in?

AOL RuLeZ,

 -dave



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




RE: IP Address

2002-04-03 Thread David Gray

 How do I get the IP address from a POST form.
 
 Let me make myself more clear: I have a form that uses POST, 
 and I would like to get users' IP address for avoiding the 
 same user to fake my pool's result.

You can check $ENV{REMOTE_ADDR}, which will contain the remote IP of the
user hitting your page.

 -dave



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




RE: Resubmit?

2002-03-28 Thread David Gray

 Is it possible to have a form submit without waiting for a 
 user to click submit? All my parameters are hidden, that's why I ask.

You could meta-refresh with all the form parameters in the query string,
or maybe javascript.submit() the form, or use a lonely continue button
:)

 -dave



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