RE: help with form

2001-12-10 Thread Bob Showalter

> -Original Message-
> From: Pedro A Reche Gallardo [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, December 08, 2001 3:06 PM
> To: [EMAIL PROTECTED]
> Subject: help with form
> 
> 
> Hi all,   I am working on a cgi script that can create  a 
> temporal file
> with either an uploaded file, or, in its absence,  the pasted 
> content of
> that file.  I have managed to upload the file only if that is the only
> input field in my form, but if I add  the choice to paste the 
> content of
> the file, there is no way I can successfully create the temporal file
> with the content of the uploaded file.   I am including with 
> this e-mail
> the html code of the form I am using together with the cgi script I am
> working on, and I will be very happy if someone could let me know why
> this thing is not working.
> Thanks.
> 
> Pedro
> 
> HTML
> 
> 
> 
> 
>test
> 
> 
> 
> 
> 
> TEST
> 
> 
> 
>  enctype="multiform/fo
> rm-data">

enctype should be "multipart/form-data", not "multiform/form-data"

> 
> 
> Enter a name for your  file:
> 
> 
> 
> 
> 
>  Upload your file
> 
> 
> 
> 
> Paste the content of your file
> 
> 
> 
> 
> 
> 
> 
> 
> CGI
> #!/usr/sbin/perl -wT
> use CGI;
> use strict;
> use Fcntl qw( :DEFAULT :flock);
> #define file paths for file writes and genscan location
> 
> 
> my $bin="/usr1/par/bin";
> my $httproot = "/usr/freeware/apache/share/htdocs/MIF/icons/";
> my $dir = "/tmp/"; #directory for writing files
> my $gnuplot = "/usr/freeware/bin/gnuplot";
> my $ppmtogif = "/usr/freeware/bin/ppmtogif";
> 
> 
> my $q = new CGI;
> print $q->header,  $q->start_html(-title=>"Variability
> Results",-bgcolor=>"white");
> print $q->h1("Variability Results");
> 
> 
> my $in= $q->param("name");
> my $file  = $q->param("file");
> my $fh= $q->upload( $file );

Use $q->upload('file')

> my $paste = $q->param("alignment");
> my $i;
> my $flen;
> 
> my $var = $^T;
> $in =~ s/\s\t//g;
> $in = $in.$var;
> 
> 
> if (!$file) {
>   open(INFILE, ">$dir/$in") || die "I cannot create $in!\n";

$in is tainted, so this will fail.

>   flock(INFILE, 2);
>   print INFILE "$paste";
>   close (INFILE) || die "can't close $dir/$in!";
> } else {
>   open(UPLOAD,">$dir/$in") or die "Can't open outfile for 

$in is tainted, so this will fail.

> writing: $!";
>   $flen = 0;
>   while (read($fh,$i,1024)) {
>   print UPLOAD $i;
>   $flen = $flen + 1024;
>   if ($flen > 512) {

Use $CGI::POST_MAX to limit post size.

>   close(UPLOAD);
>   die "Error - file is too large. Save aborted.";
>   }
>  }
> close(UPLOAD);
> }
> 
> $q->end_html;
> 
> **
> *
> 
> PEDRO A. RECHE , pHD TL: 617 632 3824
> Dana-Farber Cancer Institute,FX: 617 632 4569
> Harvard Medical School,  EM: [EMAIL PROTECTED]
> 44 Binney Street, D1510A,EM: [EMAIL PROTECTED]
> Boston, MA 02115 URL: http://www.reche.org
> **
> *
> 
> 
> 

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




RE: Perl modules on web host server

2001-12-10 Thread Bob Showalter

> -Original Message-
> From: Hoenie Luk [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 09, 2001 2:52 AM
> To: [EMAIL PROTECTED]
> Subject: Perl modules on web host server
> 
> 
> Hi, I'm new to cgi-programming with Perl and I've been 
> looking for answers 
> for the following questions:
> 
> 1. How do you find out if the web host supports certain Perl modules?

perldoc ExtUtils::Installed

> 
> 2. If the web host does not have certain modules installed 
> and I need to 
> use them for my Perl cgi-script, what can I do?

If you have a shell account, you can install modules under your home
directory and reference them from your scripts.

perldoc -q 'How do I keep my own module/library directory?'

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




Re: IP Address Reverse Lookup

2001-12-10 Thread Brett W. McCoy

On Mon, 10 Dec 2001, Brian wrote:

> If at all possible, which perl module would I need to call in order to
> perform a reverse lookup on an IP address?
>
> I need to produce something simalar to the "host" command
> ie:
>
> [brian@mustang brian]$ host 12.90.6.4
> 4.6.90.12.in-addr.arpa domain name pointer 4.philadelphia-16-17rs.pa.dial-
> access.att.net.

Take a look at Sys::Hostname (it comes standard with Perl).  It has a
bunch of IP-related functions for hostname & address lookup functions.

-- Brett
  http://www.chapelperilous.net/

The human animal differs from the lesser primates in his passion for
lists of "Ten Best".
-- H. Allen Smith


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




submit in shell/text mode

2001-12-10 Thread zaka rias

i got a html file like this :
==
#!/usr/bin/perl
print 

Hash of Hashes to set up form

2001-12-10 Thread Marcus Willemsen

Hi all,

can anybody help?
I am trying to set up a form using a hash of hashes to build different 
types of fields as I think it is easier to check and process form input:

my %fields = (textfield => { 'Name_of_textfield' => { -name => 'bla' },
'Name_of_next_textfield' => {-name => 'blo'}
},
 textarea => {'Name_of_textarea' => {-name => 'blu' }
},
 scrolling_list => {Name_of_list' => {-name => 'ble',
   -values => ['1', 
'2', '3'],
   -default => ['1']
}
   }
);
This hash of hashes is passed to a subroutine to display the from when the 
script is called on for the first time. The idea was to use the keys of the 
hash as tags for the html document.

sub form
{
my $field_ref = shift;
print start_form (-action => url());
foreach my $tag (keys (%{$field_ref})){
 my $name = (keys(%{$$field_ref{$tag}}));
 my $record = $$field_ref{$tag}{$name};
 my $label = $record->{label};
   print ($tag (-name => $record->{name}));
   }
print submit (-name => "choice", -value => "Send"),
 end_form();
}

It doesn't work I keep getting a "Can't use string ("scrolling_list") as 
symbol ref while "strict refs" in use at line number xy.
But it doesn't work either if I use "no strict 'refs'" in the subroutine. 
Then only the submit button is displayed.
I suppose it has something to do with hard vs symbolic references but to be 
honest I didn't get that part in the perldocs.
Is there a better way to solve the problem?

Thanks Marcus




Marcus Willemsen
tel: ++49(0)221 91 38 80 16
fax: ++49(0)221 91 38 80 18
www.juve.de
[EMAIL PROTECTED]
[EMAIL PROTECTED]


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




Re: Hash of Hashes to set up form

2001-12-10 Thread Curtis Poe

--- Marcus Willemsen <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> can anybody help?
> I am trying to set up a form using a hash of hashes to build different 
> types of fields as I think it is easier to check and process form input:
> 
> my %fields = (textfield => { 'Name_of_textfield' => { -name => 'bla' },
> 'Name_of_next_textfield' => {-name => 'blo'}
> },
>  textarea => {'Name_of_textarea' => {-name => 'blu' }
> },
>  scrolling_list => {Name_of_list' => {-name => 'ble',
>-values => ['1', 
> '2', '3'],
>-default => ['1']
> }
>}
> );
> This hash of hashes is passed to a subroutine to display the from when the 
> script is called on for the first time. The idea was to use the keys of the 
> hash as tags for the html document.
> 
> sub form
> {
> my $field_ref = shift;
> print start_form (-action => url());
> foreach my $tag (keys (%{$field_ref})){
>  my $name = (keys(%{$$field_ref{$tag}}));
>  my $record = $$field_ref{$tag}{$name};
>  my $label = $record->{label};
>print ($tag (-name => $record->{name}));
>}
> print submit (-name => "choice", -value => "Send"),
>  end_form();
> }
> 
> It doesn't work I keep getting a "Can't use string ("scrolling_list") as 
> symbol ref while "strict refs" in use at line number xy.
> But it doesn't work either if I use "no strict 'refs'" in the subroutine. 
> Then only the submit button is displayed.
> I suppose it has something to do with hard vs symbolic references but to be 
> honest I didn't get that part in the perldocs.
> Is there a better way to solve the problem?
> 
> Thanks Marcus

Marcus,

Several points:

1.  You are correct that strict is trying to tell you something here.  One point to 
keep in mind
that strict *usually* is trying to prevent you from doing something that you really 
don't want to
do.  There are exceptions, but usually I find that programs that ignore strict do so 
for all the
wrong reasons (for those that do so for the right reasons, read just about any module 
written by
Damian Conway).

2.  As for using a hash to create a form, this probably isn't going to work well as 
hashes store
their data in what is essentially an unordered state.  I assume that you don't want 
your form
elements to show up in random order :)

3.  Maybe it's just my email client, but it looks like you have arbitrary indentation. 
 While
consistent indentation is no guarantee of good code, inconsistent indentation is 
usually
indicative of bad code.  This is because the person coding is new to it and doesn't 
have an
identation style, the person is rather unclear regarding the scope of their code (and 
it can be
hell trying to determine the scope of a variable when code is poorly indented.  
Consider the
difference here:


my %fields = (textfield => { 'Name_of_textfield' => { -name => 'bla' },
'Name_of_next_textfield' => {-name => 'blo'}
},

Versus:

my %fields = (
textfield => { 
Name_of_textfield  => { -name => 'bla' },
Name_of_next_textfield => { -name => 'blo' }
},

The second example, while it doesn't suit everone's indentation style, is still 
clearer to read.

Now, if you still want to try to build forms in this method, I would use an array to 
preserve
order and coderefs:

#!/usr/bin/perl -wT
use strict;
use CGI qw/:standard/;

my @form;
my @fields = (
{
function => \&textfield,
args => {
-name => 'username',
-size => 20
},
},
{
function => \&password_field,
args => {
-name => 'password',
-size => 20
},
},
{
function => \&checkbox,
args => {
-name => 'saveinfo',
},
}
);

my $html = '';
foreach my $hashref ( @fields ) {
$html .= $hashref->{ function }->( $hashref->{ args } );
}
print $html;

That's going to be a bit confusing, though, and some may not find it easy to maintain.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




question about reading a page to sort information

2001-12-10 Thread Lance Prais


I am a beginning perl developer and am a little confused I was wondering if
anyone out there can give me some direction. or at the very least tell me a
good site for beginners to get information. it seem like every site is for
advanced developers

My situation is as follows I have a command that generates the a log file
with the following information I then need to parse through the page and
check to see if

TK_DISP_RUNSTATE is anything other then running or TK_END_TIME is not null.
the issue that I am confused is how do I compare the information when label
is on one line and the value is on the next.   The size to the columns is
fixed if there is no data in there then it will be filled with spaces.

my script need to do this:
1. call the function to generate the log file---done that
2. Read through and file and check for valuesLost
3. If TK_DISP_RUNSTATE is anything other then running or TK_END_TIME is not
null send out and email to page myself that the process is running--- Little
help here would be nice but I think I got this down


If anyone has done something similar to this I would appreciate some help.
I am sure it is a simple task but I an inexperience and somewhat confused.


Thank you
Lance


Siebel Enterprise Applications Siebel Server Manager, Version 6.2.1 [10232]
ENU
Copyright (c) Siebel Systems, Inc. 1995-1998.

This software is the property of Siebel Systems, Inc., 1855 South Grant
Street,
San Mateo, CA 94402-2667.
User warrants that any use of this software is governed by the terms and
conditions of the Siebel Systems Software License and Services Agreement
which
has been executed and with which the user agrees to comply.

UNAUTHORIZED POSSESSION, DISCLOSURE OR USE OF THIS SOFTWARE OR THE
INFORMATION
CONTAINED HEREIN IS PROHIBITED BY FEDERAL AND STATE LAW.

If you have received this software in error, please notify us by telephone
immediately at (650) 295-5000.

Type "help" for list of commands, "help " for detailed help

srvrmgr:CHK_SBL_DEV> list tasks for server CHK_SBL_DEV component Workflow
Monitor Agent


SV_NAME  CC_ALIAS  TK_TASKID  TK_PID  TK_DISP_RUNSTATE  CC_RUNMODE
TK_START_TIMETK_END_TIME
---    -  --    --  
---  ---
CHK_SBL_DEV  WorkMon   59458  647 Running   Background
12/06/2001 17:13:11

1 row returned.



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




Re: cgi & form

2001-12-10 Thread Mark Bergeron

How are you calling the form. You might try and including a little of your code so we 
can see what's going on.

-Original Message-
From: "Tat Nam"<[EMAIL PROTECTED]>
To: "Beginners Perl"<[EMAIL PROTECTED]>
Date: Sun Dec 09 23:01:10 PST 2001
Subject: cgi & form

>Hi,
>   I'm writing a survey form.  A cgi program processes the states of the form and 
>print out somethings and it prompts the user to enter e-mail address in a text box.  
>The user finishes the input of e-mail address. The same cgi program will call another 
>cgi program to process the input email address.  
>   I managed to work out the work separately; one cgi program to manipulate the state 
>of the form, another cgi program to process the email address.  However, when i 
>combined two cgi program into one.  It runs into trouble.  
>
>  Do anybody help on this?


___
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com



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




RE: question about reading a page to sort information

2001-12-10 Thread Herbold, John W.

>-Original Message-
>From: Lance Prais [mailto:[EMAIL PROTECTED]]
>Sent: Monday, December 10, 2001 10:08 AM
>To: [EMAIL PROTECTED]
>Subject: question about reading a page to sort information

< SNIP >
>my script need to do this:
>1. call the function to generate the log file---done that
>2. Read through and file and check for valuesLost
>3. If TK_DISP_RUNSTATE is anything other then running or TK_END_TIME is not
>null send out and email to page myself that the process is running---
Little
>help here would be nice but I think I got this down


>If anyone has done something similar to this I would appreciate some help.
>I am sure it is a simple task but I an inexperience and somewhat confused.

Try Perldoc.com, and look under the FAQ, there usualy good information 
there.

I think the commands you will want is

Regular expressions to check and see if the information exist on a line
that you read in, if so the split the line up by using the delimeter or
column locaions.  For example one that I have posted below will prompt for
a word to look for, then return information off of that record where it
is found.  Let me know if you have questions...


John Herbold
IS Specialist/DBA



#! perl -w
use CGI;
my $query = new CGI;
print $query->header;
print $query->start_html("Parse Web Log");
print "";

get_vars();
get_file();
if ($match_count > 0 ) {if ($REC) {view_detail()} else {view_data();} } 
else {$msg="No matches found for $search$total_count lines searched";
enter_date();}

sub get_vars {
$date   = $query->param('DATE');
$search = $query->param('SEARCH');
$REC= $query->param('REC');
$search = uc($search);
if ($date) {} else {enter_date();}
$year  = substr($date,2,2);
$month = substr($date,5,2);
$day   = substr($date,8,2);
$logfile = 'ex' . "$year" . "$month" . "$day" . '.log';
}


sub enter_date {
 print "";
 print "\n";
 print "\n";
 print "\n
";
 print "\n";
 print "Search Web Logs";
 print "$msg";
 print "Date to Search 
";
 print "String to Look For 
";
 print "\n ";
 print "";
 print "\n";
 print "\n ";
 print "\n";
 exit;
}

sub get_file {

$file = "c:/winnt/system32/logfiles/w3svc1/$logfile";
$total_count=0;
$match_count=0;
open(LOGFILE,$file); 
while (LOGFILE) {
 $total_count++; 
 $line = ;
 if ($line eq "") { last};
 $linetest = uc($line);
 $test = $linetest =~ m"$search";
 if ($test >0) {$match_count++; @LINE[$match_count] = $line;}
}
close(LOGFILE);
}

sub view_data {
 print "";
 $rec=0;   $date = '';   $htime = '';
$c_ip = '';   
 $cs_username = '';$s_sitename = ''; $s_computername = '';
$s_ip = ''; 
 $s_port = ''; $cs_method = '';  $cs_uri_stem = '';
$cs_uri_query = ''; 
 $sc_status = '';  $sc_win32_status = '';$sc_bytes = '';
$cs_bytes = ''; 
 $time_taken = ''; $cs_version = ''; $cs_host = '';
$cs_User_Agent = '';
 $cs_Cookie = '';  $cs_Referer = '';

 print " Rec ";
 print " Date ";
 print " Time "; 
 print " Client "; 
 print " Client Name "; 
 print " Method "; 
 print " URI "; 
 print " Status ";
 print " Win32 Status  ";
 print " SC Bytes ";
 print " CS Bytes ";
 print " Time Taken ";

 
 while ($rec <= $match_count) {
$rec++;
($date, $htime, $c_ip, $cs_username, $s_sitename, $s_computername,
$s_ip, $s_port, $cs_method, $cs_uri_stem, $cs_uri_query, $sc_status,
$sc_win32_status, $sc_bytes, $cs_bytes, $time_taken, $cs_version, $cs_host,
$cs_User_Agent, $cs_Cookie, $cs_Referer) 
= split(m"\s",@LINE[$rec]);
print "$rec";
print "$date "; 
print " $htime "; 
print " $c_ip "; 
print " $cs_username "; 
print " $cs_method "; 
print " $cs_uri_stem "; 
print " $sc_status ";
print " $sc_win32_status  ";
print " $sc_bytes ";
print " $cs_bytes ";
print " $time_taken ";
}
 print "";
exit;   
}

sub view_detail {
 print "";
 ($date, $htime, $c_ip, $cs_username, $s_sitename, $s_computername,
$s_ip, $s_port, $cs_method, $cs_uri_stem, $cs_uri_query, $sc_status,
$sc_win32_status, $sc_bytes, $cs_bytes, $time_taken, $cs_version, $cs_host,
$cs_User_Agent, $cs_Cookie, $cs_Referer) 
= split(m"\s",@LINE[$REC]);
print "Date   
$date "; 
print "Time   
$htime "; 
print "Client 
$c_ip "; 
print "User   
$cs_username "; 
print "Site   
$s_sitename "; 
print "Server 
$s_computername "; 
print "Server IP  
$s_ip "; 
print "Server Port
$s_port "; 
print "Method 
$cs_method "; 
print "STEM   
$cs_uri_stem "; 
print "Query   

printing a XML::Twig

2001-12-10 Thread Jeremy Webster


Has anyone here ever used the Twig::print method to print to a file?

I'm having trouble getting it to work.
Here is my code ($twig has already been parsed)

$ofile = '/var/www/html/tech/xml/report.xml';
$twig->set_pretty_print('indented');
$twig->print(ofile);

I get a malformed header from script. Bad header=/var...");
print ofile "hello there";
close( ofile );

Any help would be appreciated

Thanks 
Jeremy
[EMAIL PROTECTED]


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




accessing ASP functionality through Perl/CGI

2001-12-10 Thread Molly Magai

Does anyone know how to have a cgi script send a POST request to an
unrelated Web page?

Here's why: We're getting a new NT server. We currently run our pages on
CGI scripts, but we're planning to move all our hosting to ASP in the
next few months. In the meanwhile, we'll be running CGI on the new
server. Since ASP has a built-in mail function, my boss doesn't want to
go to the trouble/expense of installing SendMail on the new server for
the interim period. He has the idea that we can somehow have the CGI
scripts access an ASP page (perhaps through a POST request, but whatever
would work) and send email through ASP. I'm not doing the server
administration, but I do some scripting in Perl/CGI, and have been asked
to investigate this possibility.

I'd love to hear from anyone who has the experience to tell me: Is my
boss brilliant, or crazy? Can this be done, and if so, how?

(By the way, i'm aware that cheaper alternatives to SendMail exist -
we're looking into that too.)

Molly Magai
SurveyHost/Apian Software
(206) 547-5321 X 11 

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




Re: accessing ASP functionality through Perl/CGI

2001-12-10 Thread Kevin Meltzer

Hi Molly,

On Mon, Dec 10, 2001 at 01:11:06PM -0800, Molly Magai ([EMAIL PROTECTED]) said 
something similar to:
> Does anyone know how to have a cgi script send a POST request to an
> unrelated Web page?

Have you looked at the LWP::* modules?
 
> Here's why: We're getting a new NT server. We currently run our pages on
> CGI scripts, but we're planning to move all our hosting to ASP in the
> next few months. In the meanwhile, we'll be running CGI on the new

(ASP and Perl are both forms of CGI scripting) 

> server. Since ASP has a built-in mail function, my boss doesn't want to

ASP has it's own mail server built-in? Scary.

> I'd love to hear from anyone who has the experience to tell me: Is my
> boss brilliant, or crazy? Can this be done, and if so, how?

Why are you moving from Perl to ASP? Perl does run fine under NT (with IIS and
Apache). Anyways, look into the LWP modules which should help you with this
problem.
 
> (By the way, i'm aware that cheaper alternatives to SendMail exist -
> we're looking into that too.)

Why do you need to have the webserver and the mail server on the same box? A
small FreeBSD (Linux, etc...) box running SendMail or Postfix (what I use)
outside of the web server is pretty logical.

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Never laugh at a live dragon.
-- The Hobbit

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




help with open function

2001-12-10 Thread Lance Prais

I am using the following statement to open a document.

open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";

1. the perl.exe resides in e:\perl\bin\perl.exe
2. the workflow.txt reside is e:
3. the error I am getting is "Cannot open workflow No Such file or
directory"

What am I doing wrong.

I have tried to place them in the same directory structure and just use
open(workfloe.txt) but receive the same errors.


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




RE: help with open function

2001-12-10 Thread Herbold, John W.

Why not just tell it...

 open("e:\workflow.txt", "Workflow")|| die "Cannot open workflow $!\n";

John Herbold
IS Specialist/DBA

-Original Message-
From: Lance Prais [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 7:28 PM
To: [EMAIL PROTECTED]
Subject: help with open function


I am using the following statement to open a document.

open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";

1. the perl.exe resides in e:\perl\bin\perl.exe
2. the workflow.txt reside is e:
3. the error I am getting is "Cannot open workflow No Such file or
directory"

What am I doing wrong.

I have tried to place them in the same directory structure and just use
open(workfloe.txt) but receive the same errors.


-- 
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: help with open function

2001-12-10 Thread Lance Prais

I tried that but received the same errors, I am sure it is a simple solution
but I feel like I have tried every possible option with the same error.


-Original Message-
From: Herbold, John W. [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 3:35 PM
To: [EMAIL PROTECTED]
Subject: RE: help with open function


Why not just tell it...

 open("e:\workflow.txt", "Workflow")|| die "Cannot open workflow $!\n";

John Herbold
IS Specialist/DBA

-Original Message-
From: Lance Prais [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 7:28 PM
To: [EMAIL PROTECTED]
Subject: help with open function


I am using the following statement to open a document.

open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";

1. the perl.exe resides in e:\perl\bin\perl.exe
2. the workflow.txt reside is e:
3. the error I am getting is "Cannot open workflow No Such file or
directory"

What am I doing wrong.

I have tried to place them in the same directory structure and just use
open(workfloe.txt) but receive the same errors.


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


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




Re: help with open function

2001-12-10 Thread Kevin Meltzer

That would still not work. You are putting the cart before the horse, or
rather, the filename before the filehandle.

open(FH, "file.txt") ...

perldoc -f open
perldoc perlopentut

Cheers,
Kevin

On Mon, Dec 10, 2001 at 05:35:14PM -0600, Herbold, John W. 
([EMAIL PROTECTED]) said something similar to:
> Why not just tell it...
> 
>  open("e:\workflow.txt", "Workflow")|| die "Cannot open workflow $!\n";
> 
> John Herbold
> IS Specialist/DBA
> 
> -Original Message-
> From: Lance Prais [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 10, 2001 7:28 PM
> To: [EMAIL PROTECTED]
> Subject: help with open function
> 
> 
> I am using the following statement to open a document.
> 
> open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";
> 
> 1. the perl.exe resides in e:\perl\bin\perl.exe
> 2. the workflow.txt reside is e:
> 3. the error I am getting is "Cannot open workflow No Such file or
> directory"
> 
> What am I doing wrong.
> 
> I have tried to place them in the same directory structure and just use
> open(workfloe.txt) but receive the same errors.
> 
> 

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
There's a pizza place near where I live that sells only slices.
in the back you can see a guy tossing a triangle in the air.
-- Steven Wright

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




Re: help with upload form

2001-12-10 Thread zentara

Pedro wrote:
>Hi all,   I am working on a cgi script that can create  a temporal file
>with either an uploaded file, or, in its absence,  the pasted content of
>tha

Well, I spent sometime to learn this upload example:
Here is the solution I came up with.
There were 2 problems as far as I could tell:
1. The $fh variable was set wrong
2. $in needed to be untainted (I just copied the generic perlsec
untaint routine, so you may be able to make a better one)

#!/usr/sbin/perl -wT
use CGI;
use strict;
use Fcntl qw( :DEFAULT :flock);
#define file paths for file writes and genscan location


my $bin="/usr1/par/bin";
my $httproot = "/usr/freeware/apache/share/htdocs/MIF/icons/";
my $dir = "/tmp/"; #directory for writing files
my $gnuplot = "/usr/freeware/bin/gnuplot";
my $ppmtogif = "/usr/freeware/bin/ppmtogif";


my $q = new CGI;
print $q->header,  $q->start_html(-title=>"Variability
Results",-bgcolor=>"white");
print $q->h1("Variability Results");


my $in= $q->param("name");
my $file  = $q->param("file");
##
#my $fh= $q->upload( $file ); #Error here
my $fh= $file ;  #Should be this
##

my $paste = $q->param("alignment");
my $i;
my $flen;

my $var = $^T;
$in =~ s/\s\t//g;
$in = $in.$var;
##
# Here is my "shady" but working untaint mechanism
if ($in =~ /^([-\@\w.]+)$/){$in= $1;} 
###
if (!$file) {
  open(INFILE, ">$dir/$in") || die "I cannot create $in!\n";
  flock(INFILE, 2);
  print INFILE "$paste";
  close (INFILE) || die "can't close $dir/$in!";
} else {
  open(UPLOAD,">$dir/$in") or die "Can't open outfile for writing: $!";
  $flen = 0;
  while (read($fh,$i,1024)) {
  print UPLOAD $i;
  $flen = $flen + 1024;
  if ($flen > 512) {
  close(UPLOAD);
  die "Error - file is too large. Save aborted.";
  }
 }
close(UPLOAD);
}

$q->end_html;

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




Array Problem.

2001-12-10 Thread Andre` Niel Cameron

Hi,

I have a prob:)  I need to search threw an array and remove an item based on
its name.  I was thinking about maybie a for each loop but I am not sure how
to go about it.  Heres what I need to do:

say $object= sword;
I have an array @AllObjects('beer', 'nuts', 'sword', 'and more stuff')
Now sword may or may not ever be in the same location of the array so a
simple shift will not work here.  I need to find a way to pull sword out of
that array.  Any help is as always greatly appreciated:)


Regards,
Andre` C.
Technical Support
ԿԬ

-
Visit our support manual at http://supportmanual.com/


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




Re: help with upload form (extra)

2001-12-10 Thread zentara

I almost forgot.
The html you originally posted didn't have
a submit button.
Should be:

HTML
  
  
  
  
test 
 
 
 


TEST 
 
 
   
http://192.168.0.1/~zentara/cgi-bin/upload.cgi"; ENC
   

Enter a name for your  file:  
 

  
   

 Upload your file 

  
   

Paste the content of your file
  
  


  

 

 
  

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




Re: Array Problem.

2001-12-10 Thread Curtis Poe

--- Andre` Niel Cameron <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a prob:)  I need to search threw an array and remove an item based on
> its name.  I was thinking about maybie a for each loop but I am not sure how
> to go about it.  Heres what I need to do:
> 
> say $object= sword;
> I have an array @AllObjects('beer', 'nuts', 'sword', 'and more stuff')
> Now sword may or may not ever be in the same location of the array so a
> simple shift will not work here.  I need to find a way to pull sword out of
> that array.  Any help is as always greatly appreciated:)
> 
> 
> Regards,
> Andre` C.
> Technical Support
> ԿԬ

@AllObjects = grep { $_ ne 'sword' } @AllObjects;

Or, if you're not sure about the case:

@AllObjects = grep { $_ !~ /^sword$/i } @AllObjects;

See 'perldoc -f grep'

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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




script doesn't work under https but works under http???

2001-12-10 Thread Alex Chau

hi everybody,

I have posted a script to my server, and it works properly if I use 
http://blarblar/cgi-bin/test.pl,
but if I use https://blarblar/cgi-bin/test.pl with SSL, the browser will 
display the text instead of execute it.

Can anyone tell me what's the possible problem?

Thanks in advance.

Alex


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




Dynamic html/frames frm PERL not working

2001-12-10 Thread David Gilden

Could someone point out why the CGI script below does not work?
Thanks,
Dave


The CGI (shown below) is used to create a frameset.html file.
http://dowda.rockin.net/final/
Click on one of the left menu choices, ( using Netscape )

This is what the hrefs look like:
Intro
Another File...


This works fine in I.E. 5.5 on a Mac, but does not work in Netscape or on Windows,
in these cases the script returns the following html:


# HTML Page out
http://www.w3.org/TR/REC-html40/frameset.dtd";>
Frame Setter for Gallery





Please upgrade your web browser, this section uses frames





[SCRIPT]


#!/usr/bin/perl -w

# creates frame setting html document
# Last modified: Monday, December 10, 2001 2:39 PM

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);

my $pageName =  $ENV{"QUERY_STRING"} || 'intro';  


print header;

print 
Frame Setter for \u$pageName





Please upgrade your web browser, this section uses frames

HTML
exit

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




Re: cgi & form again

2001-12-10 Thread Tat Nam

Hi,
   The following scripts processes the form and write somthings out and then
allow the user to input his/her e-mail address.  After input of the e-mail
address, the script write it into a flat file.  However, the script runs
into trouble.

Help!


#!/usr/local/bin/perl -wT

use strict;
use CGI;
use Fcntl ":flock";

open (OUTF, ">>db1.txt") || die;
flock(OUTF,2);
seek(OUTF,0,2);

my $q = new CGI;
my( $name, $value );
my $dietary = 0;


foreach $name ( $q->param ) {
   print OUTF "$name:";
   foreach $value ( $q->param( $name ) ) {
  print OUTF " $value |";

  if (( $name eq 'q4a' ) || ($name eq 'q4b' ) || ( $name eq 'q4c' ) ||
( $name eq 'q4d' ) ) {
 if ($value <= 3) {
 $dietary++;
 } #end
  } #end

   }
}
print OUTF "\n";

close(OUTF);

print $q->header( "text/html" );
print $q->start_html( -title => "Survey Result", -bgcolor => "#ff" );
print $q->p( " Survey ");
print $q->hr;

if ( $dietary >= 19 ) {
   print $q->p( "Dietary marks count:", $dietary );
   print $q->p( " Dietary Habit Health Advice 2 " ) ;
   }

if ( $smoking >= 1 ) {
   print $q->p( "Health Advice 4, Smoking marks count:", $smoking ) ;
   print $q->p( " You have to stop smoking as soon as possible  " ) ;

print $q->endform;

&print_prompt($q);
&do_work($q);
print $q->end_html;


sub print_prompt {
   my($query) = @_;

   print $query->start_form;
   print "What's your e-mail address? ";
   print $query->textfield('ename');
   print ;
   print "",$query->reset;
   print $query->submit;
   print $query->endform;
   print "\n";
}

sub do_work {
   my($query) = @_;
   my($name,$value);

   open (OUTF, ">>dbemail.txt") || die;
   flock(OUTF,2);
   seek(OUTF,0,2);
   foreach $name ( $query->param ) {
  foreach $value ( $query->param( $name ) ) {
 print OUTF "$value\n";
 print "Thank you for your enquiries, you'll be contacted
shortly\n";
  }
   }
   close(OUTF);
}




- Original Message -
From: "Mark Bergeron" <[EMAIL PROTECTED]>
To: "Tat Nam" <[EMAIL PROTECTED]>; "Beginners Perl" <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2001 1:06 AM
Subject: Re: cgi & form


> How are you calling the form. You might try and including a little of your
code so we can see what's going on.
>
> -Original Message-
> From: "Tat Nam"<[EMAIL PROTECTED]>
> To: "Beginners Perl"<[EMAIL PROTECTED]>
> Date: Sun Dec 09 23:01:10 PST 2001
> Subject: cgi & form
>
> >Hi,
> >   I'm writing a survey form.  A cgi program processes the states of the
form and print out somethings and it prompts the user to enter e-mail
address in a text box.  The user finishes the input of e-mail address. The
same cgi program will call another cgi program to process the input email
address.
> >   I managed to work out the work separately; one cgi program to
manipulate the state of the form, another cgi program to process the email
address.  However, when i combined two cgi program into one.  It runs into
trouble.
> >
> >  Do anybody help on this?
>
>
> ___
> GO.com Mail
> Get Your Free, Private E-mail at http://mail.go.com
>



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