Best Practices for Debugging and Error Handling in CGI Scripts?

2002-08-15 Thread David Simcik

Can anyone list some resources or methods they use for debugging (Perl) CGI
scripts. How can I use CGI::Carp most effectively?

Does anyone have any recommended practices for graceful CGI error handling?
Is this something that should be built in a custom module for my site?

Sorry if these are "softball" questions.

Cheers,
D. Simcik


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




Net::SMTP Question

2002-04-11 Thread David Simcik

I've been experiencing a weird behavior lately with one of my messaging
scripts. I keep on seeing msg recipients getting BCC'd a copy of the msg, in
addition to their listing in the To: field. I have no idea why, but it seems
to have something to do with the "hard" ->recipient method call - but when I
remove it, my scripts break. I'm thinking this should be pretty trivial. If
anyone has any thoughts on a better form of error handling for this I'm all
ears.

My src:

sub sendmsg
{

#Connect to SMTP server and start session
$smtp = Net::SMTP->new('mydomain.com', Timeout=> 15, Debug=>0) or die(
"Could not find SMTP server!\n");

#Hard listing of sender(s)
$smtp->mail($FORM{'requestorsemail'}) or die( "Could not specify sender! "
.. $!), "\n";

#Hard listing of recipient(s)
$smtp->recipient($FORM{'recipient'}) or die ("Message could not be sent! ".
$!), "\n";

#Start data
$smtp->data();

#Soft listing of recipient(s)
$smtp->datasend("To: $FORM{'recipient'}\n");

#Soft listing of sender(s)
$smtp->datasend("From: $FORM{'requestorsemail'}($FORM{'requestor'})\n");

#Subject
$smtp->datasend($mysubject);

#Message Body
$smtp->datasend(@MAIL_CONTENT);

#Wrap up message body
$smtp->dataend();

#Quit SMTP server
$smtp->quit();

}



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




A Model for Perl-driven HTML/WML/XML Front-Ends???

2002-01-03 Thread David Simcik

Hello out there!
I am currently trying to piece together a personal site for myself using
Perl, MySQL, and Apache (alas, no mod_perl yet). I would like to seamlessly
deliver content to both HTML and WML browsers, perhaps even going as far as
deploying SOAP or XML-RPC as well (the difference, anyone?) for more
traditional fat clients I might have down the road.

In essence, I am wondering what is the best model to emulate when I start
putting together these apps? I have heard that the XSLT/XML method using
[CGI] scripts to route requests, while much ballyhooed, can be a pain to
implement because of XSLT. I am also wondering how one can handle the myriad
of WAP/WML browsers out there, but perhaps that is a question for another
list.

Any recommendations???

Thanks!
DTS


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




References vs. Pointers???

2001-09-25 Thread David Simcik

Hello,
This is a newbie question if there ever was one, but what is the difference
between a (Perl) reference and a (C/C++ style) pointer??? The only thing
that seems immediately obvious is that C/C++ pointers are strongly
typed...???


Hmmm.
DTS


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




Security Mechanisms with Perl/Apache on an Hosted Website???

2001-09-25 Thread David Simcik

Hey folks,
I'm trying to cobble together some form of authentication mechanism on a
website I am building for a friend. His ISP uses Perl & Apache (it's on a
linux box). I (obviously) don't have root priviledges and have limited
access to the filesystem. What are my options (if any)??? I think some form
of session management would go hand-in-hand with the authentication.

Thanks!
DTS


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




RE: any lists for perl for NT/W2K admin?

2001-09-19 Thread David Simcik

Check out the ActiveState lists beginning here: 

http://aspn.activestate.com/ASPN/Mail/

(I just went looking for this info yesterday, in fact ;-)

-Original Message-
From: Edouard Beaugard [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 3:30 PM
To: [EMAIL PROTECTED]
Subject: any lists for perl for NT/W2K admin?


Hi,

if anyone knows of one please let me know.

Thanks,
Ed




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




XML sections ?

2001-09-19 Thread David Simcik

Hi!
A little off-topic I know, but since I'm using Perl for the script, well...
;-) Anyways, I have an XML document and I want to use 
(whatever its type is actually called) to keep some content from being
parsed by the parser. Problem is, I keep on getting error messages like this
"The  must end in ]]>". From my point of view they are ending
with ]]>! I even tried the Xerces-J parser; it returned the same results.
Here is a code snippet:








]>



Could not authenticate user!
Blah Blah Blah






Maybe it's a whitespace problem. Any thoughts (I hope it's a silly
problem)???




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




Win32::NetAdmin::UserCreate() Problems!

2001-09-18 Thread David Simcik

Hello again,
I'm working with ActiveState Perl and am trying to make use of a Win32 call
to create new users. I'm not having much success. Every time my sub runs it
returns this error: "Overlapped I/O operation is in progress". I am using
the function Win32::NetAdmin::UserCreate(). I setup IIS to operate with
local Admin priv's for the application directory my CGI script resides in.
Any ideas???

Here's my code snippet:

#Create new user
(!createNewUser($user, $pass))? print "Could not create new local user
account!: $^E" : print "Created user account!";

sub createNewUser
{
my ($user, $pass) = @_;

%account = {
homedir => ' ',
priv=>  USER_PRIV_USER,
flags   => UF_SCRIPT | UF_NORMAL_ACCOUNT,
fullname=> $user,
comment => ' ',
logon   => ' '
};

#first, check to see if user account exists for some bizarre reason
#if (! Win32::NetAdmin::UsersExist('', $user))
#{
if (Win32::NetAdmin::UserCreate ('0050DA8430C4', $user, $pass, 0,
$account{privs}, $account{homedir}, $account{comment}, $account{flags},
$account{logon}) )
{
return 1;
}
else #account creation failed
{
return ;
}

#}
}


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




RegExp Problem...

2001-09-18 Thread David Simcik

Hi folks,
I'm stumped...I wrote a test script and this pattern matches just fine, but
when I try to use it in another script it does match as it should.
Basically, if the pattern detects an _ underscore in the string it should
return undef; if it doesn't match it returns true. Here's some code:

if(isFacStaff('xty_1233'))
{
print "Is Faculty/Staff!\n";
}
else
{
print "Is Student!\n";
}


sub isFacStaff
{
my $id = @_;

#this will match student-style ID's
#it is rather easier to match against student IDs than staf IDs
if($id =~ m/^.+_.+$/i)
{
return;
}
else
{
return 1;
}
}

Thanks in advance for any help!
DTS


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




Problem Building Module...

2001-09-17 Thread David Simcik

Hi all,
Trying to build XML-XPath.pm. I keep on getting this error when I run make
(Win 2000, recent ActiveState Perl Build):

Makefile:740: *** missing separator.  Stop.

I'm hoping it's a silly problem, but I'm pretty clueless when it comes to
Make.

Thanks!
DTS


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




Win32::FileSecurity::Set() Woes

2001-09-14 Thread David Simcik

Hey folks,
To sum things up, I've got two servers: one in an NT Domain and one not in
an NT Domain. I would like to set NTFS permissions on shared directories
residing on the server in the NT Domain using a Perl/CGI script running off
of the other server without a domain. Big Problem. I've been lulled into a
sense of confidence about the succes of this setup up until now by my
somewhat innapropriate testing environment and a woeful lack of NT/2000
security programming experience.

In other words, everything worked fine until I tried to actually put this
into production. Win32::FileSecurity::Set() has no way of determing username
SID's unless it somehow has access to that user's NT Domain, from what I can
tell. You just can't get away with setting MYDOMAIN\user on a shared
directory from the CGI script in this setup. Everything is dependent on
resolving SIDs. This makes perfect sense in hindsight, of course.

So, am I wrong??? Is there a way out of this mess? I'm sure I glossed over
more than a handful of details for the sake of expendiency. Does someone
have a module or COM object they can suggest to fullfill this task? If I
could lookup a username against a specific NT Domain (PDC & BDC controllers
or otherwise) to return an SID and then set that SID on the directory
permissions somehow (that part might be trivial in fact) via Win32API calls
in C this might just have a chance of working.

Can anyone shed any light on this situation???

Many Thanks,
DTS


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




A Framework for Building An WML/HTML Application Using Perl???

2001-09-10 Thread David Simcik

Hey all,
I'm trying to modify an existing script that searches a test file for what
one could qualify as normal phonebook style entries; name, phone #, email
addy, etc. We've got an internal presentation coming up in two weeks, and my
boss would like to WAP-ify this directory for it. That almost certainly
means moving the app to produce an XML doc of some kind. Ideally, I would
like to use XSLT to convert the raw XML doc into WML and HTML; to seperate
data from presentation of course. The Perl script would handle the actual
search mechanism, any logic required to detect different browsers, and the
handling of the XSL transformations.

Can anybody provide a few pointers on the best approach to take with this?
More specifically, any recommended modules that could be used to facilitate
this? How can I detect different WAP browsers???

Thanks!
DTS


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




Access Denied When Trying to Create Directory?

2001-09-04 Thread David Simcik

Hey all,
I'm simply trying to create a directory on a mapped (remote) drive from a
CGI script using the mkdir() function. I keep on getting "Access Denied"
errors or the like every time I try to create a new directory. What do I
need to do to assign the proper rights to my script so it can work??? I
suppose it should be a simple fix, but my brain is presently in stealth mode
and hiding.

 Running on Windows NT 4.0 system with IIS 4 running ActiveState Perl
(recent build).

Thanks!
DTS


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




Searching for Particular XML Element Values???

2001-08-22 Thread David Simcik

Hey folks,
I'm working on a simple app that doesn't allow for any true DB persistent
storage/access of data. I only need a small amount of data access anyways,
but I would like to structure it a bit via XML/DTD. What I'd REALLY like to
do is have the ability to search the entire XML document (like a DB in some
ways) for a particular value or element attribute via a parser. Sort of the
equivalent to a SELECT * FROM MYTABLE WHERE myfield='xyz' inner join type
statement. The only other alternative ,given my requirements, that I can
think of would be to load the entire XML document into a hash of hashes, the
first element for each record representing the name of the record. It sound
terribly inneficient to have to load the entire document into memory though.

I hope I am not over-analyzing this. Anyone have any ideas???


Thanks.
DTS



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




Checking for Directory Existence

2001-08-16 Thread David Simcik

Hey folks,
This would seem to be a trivial thing, but I can't find a great answer
anywhere for it. I want to do a mkdir, but before I do, I want to confirm
that the dir I'm about to make doesn't already exist.

Would the -X operators (particularily -e) work with DIRHANDLES??? That would
certainly make my life easier. Otherwise, the only other option I can think
of is to do a Opendir() before the Mkdir and test to ensure that the Opendir
fails. That's a bit kludgey in my mind, so can anyone shed some light on the
situation?

THanks!
DTS


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




Passing Scalar Reference to Subroutine

2001-08-16 Thread David Simcik

Newbie question here...

I've created a CGI.pm object and want to pass its reference to a function.
It keeps on puking though, returning this message:

Type of arg 1 to main::isPresent must be scalar (not single ref constructor)
at C:\src\Orion\cgi-bin\share.pl line 45, near "$user)"

Basically, I'd like to treat the $req CGI.pm object as just that in the
function call isPresent(). Maybe not the best use of a reference, but I'm
hellbent on figuring out this reference thing first! ;-)


Here's the offending source (I've left out code for brevity). Please note
that I have set this function up in prototype form (mostly for posteirity):

sub isPresent(\$$);

our $req = new CGI();

if(!isPresent(\$req, $user))
{

print "User not present\n";
}
elsif (!isPresent(\$req, $pass))
{

print "Password not present\n";
}
elsif (!isPresent(\$req, $agreed))
{

print "Agreement not present\n";
}

sub isPresent(\$$)
{

my $qref = shift;
my $paramname = shift;
my $query = $$qref;

if($query->param($paramname) =~/""/ || !defined ($query->param($paramname))
{
#return;
}

#otherwise...
return 1;
}






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




Best Practices: Error Handling???

2001-08-14 Thread David Simcik

I've been perusing the Camel book, the Cookbook, CGI Programming w/Perl, and
Effective Perl for answers to this question, but have yet to find one or two
definitive solutions. I've seen the standard die/eval() statements and the
use of the various incarnations of Carp, but I have yet to see anyone say
something along the lines of "this is the most common approach". I find
myself longing for the consistency of try/catch blocks. Can anyone shed some
light on the situation?

Regards,
DTS


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




Perl and Date Handling

2001-07-30 Thread David Simcik

Hey folks,
I'm about to embark on some serious beginner date manipulation and I was
wondering if anybody had ANY pointers about handling dates. I'm specifically
interested in working with the different date formats DD/MM/,
MM/DD/, Dec 12 2000, etc. etc. What about working with the DATE datatype
for Oracle and MySQL via DBI???

THANKS!
DTS


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




Gzip on Win32

2001-06-28 Thread David Simcik

Hey,
I'm hoping this will be a straighforward question...I'm assuming I need a
command-line interface GZip utility to work with the MCPAN installation
utility??? Where can I find one?

Thanks.
DTS




Perl Boilerplate???

2001-06-28 Thread David Simcik

Hey,
I, like the rest of you, am always looking for ways to make my life more
convenient. Especially when coding. To this end, I am looking to fashion a
well-rounded template doc that I can use in Homesite (where I do most of my
work right now) made up of the essential pieces I'd expect to work with in
Perl and with a strong layout. I have trolled through most of the better
Perl books out there (Camel, Cookbook, Effective Perl, CGI Programming), but
have yet to find an example template outlined succintly (aside from the VERY
basic). So the question is, if anybody else does this (I'd be shocked if no
one did), what do YOUR templates looks like? What are some of the
idiomatically most important elements that should be included???

Regards,
DTS