Win NT Formmail and opening temporary files 
Author Message
 Win NT Formmail and opening temporary files

Hello,


response so I thought I'd see if I can get any help on this newsgroup.

I'm kind of new at this so forgive me if I'm asking for something that
has been rehashed to death.  I'm using Matt Wright's formmail.pl file with
some modifications to make it work with softmail instead of Windmail.  I
can run this once with success.  However if I do not unlink the temporary
file nor manually delete the temporary file, I can not run again.  It just
hangs.  I have eliminated execution of softmail.exe so all the send_mail
portion of formmail.pl file does is create $tempfile and it still fails.
I have limited the problem to the following line:

Open(MAIL,">$tempfile") || die ("Cannot open $tempfile - Check Directory
Permissions : $!");  

If the file already exists, the open appears to hang.  If I test for
existance of $tempfile and attempt to unlink it before the open, that also
hangs. The NT system I am using is using NTFS.  I've tried chmod, and
SetAttributes to no avail.  Do I have to set the file permissions in the
formmail.pl file using Win32::FileSecurity?  Any
answers/help/explainations/directions/etc. would be appreciated.

Thanks,

John



Sun, 28 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files


Quote:

>I'm kind of new at this so forgive me if I'm asking for something that
>has been rehashed to death.  I'm using Matt Wright's formmail.pl file with
>some modifications to make it work with softmail instead of Windmail.  I
>can run this once with success.  However if I do not unlink the temporary
>file nor manually delete the temporary file, I can not run again.  It just
>hangs.  I have eliminated execution of softmail.exe so all the send_mail
>portion of formmail.pl file does is create $tempfile and it still fails.
>I have limited the problem to the following line:

>Open(MAIL,">$tempfile") || die ("Cannot open $tempfile - Check Directory
>Permissions : $!");  

>If the file already exists, the open appears to hang.  If I test for
>existance of $tempfile and attempt to unlink it before the open, that also
>hangs. The NT system I am using is using NTFS.  I've tried chmod, and
>SetAttributes to no avail.  Do I have to set the file permissions in the
>formmail.pl file using Win32::FileSecurity?  Any
>answers/help/explainations/directions/etc. would be appreciated.

I'm assuming you are using IIS as your web server, though the suggestion would
remain the same for any other web server:

Ask your system administrator to set "CHANGE" file permissions for the
Anonymous Web User (e.g. IUSR_xxx) for your cgi-bin directory and all
subdirectories.  Most likely you have only read permissions which denies you
the write to create new or modify existing files.

Followups set to: microsoft.public.inetserver.iis

--
Ethan H. Poole            | Website Design and Hosting,
                          | CGI Programming (Perl & C)..
========Personal========= | ============================

http://home1.gte.net/ehp/ | http://www.interact2day.com/



Mon, 29 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files

Quote:
>Hello,


>response so I thought I'd see if I can get any help on this newsgroup.

>I'm kind of new at this so forgive me if I'm asking for something that
>has been rehashed to death.  I'm using Matt Wright's formmail.pl file with
>some modifications to make it work with softmail instead of Windmail.  I
>can run this once with success.  However if I do not unlink the temporary
>file nor manually delete the temporary file, I can not run again.  It just
>hangs.  I have eliminated execution of softmail.exe so all the send_mail
>portion of formmail.pl file does is create $tempfile and it still fails.
>I have limited the problem to the following line:

Why would you want the tempfile{*filter*} around anyway?  One problem in
doing it this way is if you have multiple users using the script at
one time there can be a problem with the tempfile.  I use the
following rand routine to generate a unique tempfile, and then unlink
it after the mail is sent.

# Create Tempfile name

 srand;

$tempfile='temp'.int(rand(9)).int(rand(9)).int(rand(9)).int(rand(9)).'.txt';

# Output a temporary file

open(MAIL,">$tempfile") || die("Cannot open tempfile -- Check
Directory Permissions : $!");

Quote:
>Open(MAIL,">$tempfile") || die ("Cannot open $tempfile - Check Directory
>Permissions : $!");  

>If the file already exists, the open appears to hang.  If I test for
>existance of $tempfile and attempt to unlink it before the open, that also
>hangs. The NT system I am using is using NTFS.  I've tried chmod, and
>SetAttributes to no avail.  Do I have to set the file permissions in the
>formmail.pl file using Win32::FileSecurity?  Any
>answers/help/explainations/directions/etc. would be appreciated.

>Thanks,

>John

I hope this helps.
Bill


Mon, 29 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files
peaceml here

Quote:

> Why would you want the tempfile{*filter*} around anyway?  One problem in
> doing it this way is if you have multiple users using the script at
> one time there can be a problem with the tempfile.  I use the
> following rand routine to generate a unique tempfile, and then unlink
> it after the mail is sent.

In reality the file is not a temporary file but a SENDMAIL.INI required
by softmail.exe, which will contain information extracted from the
form.  The SENDMAIL.INI needs to go into the Windows System Directory
(i.e. WinNT).  The problem I have is that I run softmail.exe with the
the system command (much like Matt's starting of Windmail) from the perl
script, I can't unlink the SENDMAIL.INI file (my guess is that since
softmail is using the file, the unlink command fails and the file is
left{*filter*} around).  
Quote:

> # Create Tempfile name

>  srand;

> $tempfile='temp'.int(rand(9)).int(rand(9)).int(rand(9)).int(rand(9)).'.txt';

> # Output a temporary file

> open(MAIL,">$tempfile") || die("Cannot open tempfile -- Check
> Directory Permissions : $!");

I don't have the luxury of using the random file name because
softmail.exe requires a SENDMAIL.INI file.  Maybe I'll try another
mailer program (suggestions are welcomed).

Quote:

> I hope this helps.
> Bill

Thanks for trying.
John


Mon, 29 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files
Quote:



> >I'm kind of new at this so forgive me if I'm asking for something that
> >has been rehashed to death.  I'm using Matt Wright's formmail.pl file with
> >some modifications to make it work with softmail instead of Windmail.  I
> >can run this once with success.  However if I do not unlink the temporary
> >file nor manually delete the temporary file, I can not run again.  It just
> >hangs.  I have eliminated execution of softmail.exe so all the send_mail
> >portion of formmail.pl file does is create $tempfile and it still fails.
> >I have limited the problem to the following line:

> >Open(MAIL,">$tempfile") || die ("Cannot open $tempfile - Check Directory
> >Permissions : $!");

> >If the file already exists, the open appears to hang.  If I test for
> >existance of $tempfile and attempt to unlink it before the open, that also
> >hangs. The NT system I am using is using NTFS.  I've tried chmod, and
> >SetAttributes to no avail.  Do I have to set the file permissions in the
> >formmail.pl file using Win32::FileSecurity?  Any
> >answers/help/explainations/directions/etc. would be appreciated.

> I'm assuming you are using IIS as your web server, though the suggestion would
> remain the same for any other web server:

> Ask your system administrator to set "CHANGE" file permissions for the
> Anonymous Web User (e.g. IUSR_xxx) for your cgi-bin directory and all
> subdirectories.  Most likely you have only read permissions which denies you
> the write to create new or modify existing files.

peaceml here (no matter what the mail header says)
I am using IIS 2.0.  The directory containing the tempfile and tempfile
itself were all set to Everyone Full Control (not a secure idea, I know,
but it is a localized test).   I tried just specifying IUSR_name with
CHANGE only for the temporary file and its directory to no avail.  The
mailform.pl file is operating out of the c:\scripts directory on the
server.  Does this make a difference since the temporary file is in a
complete different directory?  Do I have to reboot after making
changes?  Can I even do this with IIS 2.0?  Thanks.

John



Mon, 29 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files

Quote:

>I don't have the luxury of using the random file name because
>softmail.exe requires a SENDMAIL.INI file.  Maybe I'll try another
>mailer program (suggestions are welcomed).

Well, I tried to help you out (on 2 different posts) via email, but
unfortunately your provider's SMTP server does not like my return email address

<rant mode on>
I really wish ISP's would quit rejecting email simply because it was sent by an
SMTP server behind a firewall, it really doesn't do a damn thing to curb spam.  
It just causes people like myself to waste valuable time trying to help people
who will never receive the help because I simply don't feel like going to the
trouble of retyping the whole thing and being forced to send it from aol or
compuserve (which is even more likely to be rejected simply because of the
domain name)!
</rant>

--
Ethan H. Poole            | Website Design and Hosting,
                          | CGI Programming (Perl & C)..
========Personal========= | ============================

http://home1.gte.net/ehp/ | http://www.interact2day.com/



Tue, 30 Jan 2001 03:00:00 GMT  
 Win NT Formmail and opening temporary files

Response follows below.  E-mail sent to author.

Quote:
>peaceml here


>> Why would you want the tempfile{*filter*} around anyway?  One problem in
>> doing it this way is if you have multiple users using the script at
>> one time there can be a problem with the tempfile.  I use the
>> following rand routine to generate a unique tempfile, and then unlink
>> it after the mail is sent.

>In reality the file is not a temporary file but a SENDMAIL.INI required
>by softmail.exe, which will contain information extracted from the
>form.  The SENDMAIL.INI needs to go into the Windows System Directory
>(i.e. WinNT).  The problem I have is that I run softmail.exe with the
>the system command (much like Matt's starting of Windmail) from the perl
>script, I can't unlink the SENDMAIL.INI file (my guess is that since
>softmail is using the file, the unlink command fails and the file is
>left{*filter*} around).  

>> # Create Tempfile name

>>  srand;

>> $tempfile='temp'.int(rand(9)).int(rand(9)).int(rand(9)).int(rand(9)).'.txt';

>> # Output a temporary file

>> open(MAIL,">$tempfile") || die("Cannot open tempfile -- Check
>> Directory Permissions : $!");

>I don't have the luxury of using the random file name because
>softmail.exe requires a SENDMAIL.INI file.  Maybe I'll try another
>mailer program (suggestions are welcomed).

Why don't you install BLAT?  Iw works great as a command line mail
interface, and Matt even has a script to use it.  Another solution
would be to use a script with a sockets routine.  Below is a library
routine to work with Selena Sol's form_processor.pl.  Just rename it
mail-lib.pl and put it in the Library subdir.  This can be used as a
send_mail subroutine for many e-mail scripts.

Good Luck
Bill

######## BEGIN CODE##########

sub send_mail  ###sockets_mail
{
local $smtp_addr = 'ADDRESS OF YOUR SMTP SERVER HERE';
local $from = 'YOUR E-MAIL ADDRESS HERE';  


    my ($replyaddr) = $email_of_sender;

    if (!$email_to) { return -8; }

    my ($proto, $port, $smptaddr);

    my ($AF_INET)     =  2;
    my ($SOCK_STREAM) =  1;

    $proto = (getprotobyname('tcp'))[2];
    $port  = 25;

    $smtpaddr = ($smtp_addr =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
                    ? pack('C4',$1,$2,$3,$4)
                    : (gethostbyname($smtp_addr))[4];

    if (!defined($smtpaddr)) { return -1; }

    if (!socket(S, $AF_INET, $SOCK_STREAM, $proto))             {
return -2; }
    if (!connect(S, pack('Sna4x8', $AF_INET, $port, $smtpaddr))) {
return -3; }

    my($oldfh) = select(S); $| = 1; select($oldfh);

    $_ = <S>; if (/^[45]/) { close S; return -4; }

    print S "helo localhost\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }

    print S "mail from: $from\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }

    print S "rcpt to: $email_to\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -6; }

    print S "data\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }

    print S "X-Mailer: SMTP Sendmail \r\n";
    print S "Mime-Version: 1.0\r\n";
    print S "Content-Type: text/plain; charset=us-ascii\r\n";
    print S "To: $email_to\r\n";
    print S "From: $email_of_sender\r\n";
    print S "Reply-to: $replyaddr\r\n" if $replyaddr;
    print S "Subject: $email_subject\r\n\r\n";
    print S "$email_body";
    print S "\r\n.\r\n";

    $_ = <S>; if (/^[45]/) { close S; return -7; }

    print S "quit\r\n";
    $_ = <S>;

    close S;
    return 1;

Quote:
}

1;
############ END CODE ###############

- Show quoted text -

Quote:

>> I hope this helps.
>> Bill

>Thanks for trying.
>John



Tue, 30 Jan 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. open won't open files in subdirectories?

2. Help with Recursive Opens (Win NT)

3. DBM file won't open

4. Perl won't open file

5. PERL CGI won't Open file for Append

6. PERL CGI won't Open file for Append

7. File Upload question - using perl on IIS 3.0 (Win NT)

8. Win NT file access mask in perl

9. file size with perl and win NT

10. File Upload question - using perl on IIS 3.0 (Win NT)

11. Win NT file access mask in perl

12. Printing a binary file under Win NT

 

 
Powered by phpBB® Forum Software