Manesh Rao wrote:
> 
byron wise <[EMAIL PROTECTED]> wrote:
>
> >I have a perl script that accepts file uploads.  When the file uploads are
> >recieved, the user is wwwrite. I am unable to go back in and delete files
> >because of this(Permission is denied ).  I'd like to change the user on the
> >upload but I'm not sure how to do this.
> 
> Have you instead considered changing the permission of the files after they
> have been uploaded??
> 
> in the same script where you are doing the upload, after all processing has
> been done and the file handle to the uploaded file has been closed, you can
> use the chmod function of PERL to give the uploaded file proper permissions.
> 
> Eg. let say the file you have uploaded is /tmp/001254_1.pdf
> 
> close(UP_FILE_HANDLE);
> 
> $cnt = chmod (0775, '/tmp/001254_1.pdf')
> 
> if ($cnt){ ## chmod worked!!
> ## Do soemthing here
> }
> 
> Another alternative would be to write a admin script, that would delete
> these files for you. Since this script would also run under user wwwrite,
> you will not have any permissions issues to delete the file.
> 
> Hope that helps
> 
> >-rwxrwx---   1 www      wwwrite    71310 Jan  4 14:04 0012547_4.pdf*
> >-rw-------   1 www      wwwrite    56694 Dec 21 13:01 001254_1.pdf
> >-rwxr-x---   1 www      wwwrite  4040938 Dec 26 11:49 001254_2.pdf*
> >
> >
> >Perhaps part of this problems lies with the fact I create direcories on the
> >fly and put these files into them.
> >
> >any help would be appreciated,

Setting umask to 0 will give world write/delete access if that's OK.
Then you don't need the chmod.

my $oldmask = umask 0;

# now mkdir or open your output file

umask $oldmask; # restore umask if you like

Optionally as mentioned, just use a CGI script to delete the files since 
they run as www/wwwrite.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.todbe.com/
  / ) /--<  o // //      Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to