Code Comments
Programming Forum and web based access to our favorite programming groups.is there such a thing as a perl / cgi script that will do a CHMOD on a specified file - in a specified directory..... siggy
Post Follow-up to this messagesiggy wrote: > is there such a thing as a perl / cgi > script that will do a CHMOD on a > specified file - in a specified directory..... Don't know, but there is a Perl function that does just that. perldoc -f chmod -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this message"siggy" <this_is_me_sigma@accesscomm.com> wrote in message news:41685d72$1@news.accesscomm.ca... > is there such a thing as a perl / cgi > script that will do a CHMOD on a > specified file - in a specified directory..... Congratulations!! You've earned an entry in the Perl SAQ. http://www.ginini.com/perlsaq.html
Post Follow-up to this messageIn message <2sra42F1mlv59U1@uni-berlin.de> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: > Don't know, but there is a Perl function that does just that. > perldoc -f chmod It doesn't, you know. I wrote a Perl script to create a directory and install a file in it which another user could access. I was carefull to chmod appropriately. Both directory and file are now sitting in my cgi-bin: the user can't access them, I can't delete them. The problem, apparently, is that I am not the "owner" of the file/directory. If anyone has a solution to the problem, I'm eager to hear from them. Ken Down -- ================ ARCHAEOLOGICAL DIGGINGS =============== | Australia's premiere archaeological magazine | | http://www.diggingsonline.com | ======================================== ================
Post Follow-up to this message"Kendall K. Down" <webmaster@diggingsonline.com> wrote in message news:758092fb4c.diggings@diggingsonline.com... > In message <2sra42F1mlv59U1@uni-berlin.de> > Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: > > > > It doesn't, you know. > It does. You seem to have the common problem of not understanding how permissions work in the CGI environment, though. Just because a script was written by you does not mean it will be run as you by the server. You need to change the way you set the permissions accordingly. Matt
Post Follow-up to this messageKendall K. Down wrote: > I wrote a Perl script to create a directory and install a file in > it which another user could access. I was carefull to chmod > appropriately. Both directory and file are now sitting in my > cgi-bin: the user can't access them, I can't delete them. Then you did apparently *not* chmod them carefully. > The problem, apparently, is that I am not the "owner" of the > file/directory. In that case, your Perl script is a CGI script, and CGI is run as some other user but you. > If anyone has a solution to the problem, I'm eager to hear from > them. Read up about the Unix/Linux file permissions system. You can't change permissions of that directory and file e.g. via your FTP client, but you can have your CGI script do it using the Perl chmod() function. If you e.g. want anybody being able to read the file, you can set the directory permission 755 and file permission 644. You can also have the CGI script delete the file, since the user CGI is run as owns the directory. The directory itself can well be deleted via your FTP client, since *you* (I assume) own the directory in which the script generated directory is located. HTH -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this messageIn article <2srd1vF1iiooeU1@uni-berlin.de>, Peter Sundstrom wrote: snipped to save someones embarassment > Congratulations!! You've earned an entry in the Perl SAQ. > > http://www.ginini.com/perlsaq.html I've had to bookmark that it's so much fun. Damn glad I didn't make the list 'cos I know I've asked some damned dum questions! Though the Llama is a great teacher it doesn't go far enough, it doesn't teach us the value of perldoc - or it doesn't go far enough in showing the path! Maybe Randal and Tom can rectify this in the next version?! Justin. -- Justin C, by the sea.
Post Follow-up to this messageIn message <CJgad.10308$3C6.248852@news20.bellglobal.com> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote: > It does. You seem to have the common problem of not understanding how > permissions work in the CGI environment, though. Just because a script was > written by you does not mean it will be run as you by the server. You need > to change the way you set the permissions accordingly. That is entirely possible; I am a Perl newbie. So *please*, tell me what to do! Ken Down -- ================ ARCHAEOLOGICAL DIGGINGS =============== | Australia's premiere archaeological magazine | | http://www.diggingsonline.com | ======================================== ================
Post Follow-up to this messageIn message <2stmfmF1p25fcU1@uni-berlin.de> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote: > In that case, your Perl script is a CGI script, and CGI is run as some > other user but you. Yes, it is and yes, I have already identified that as the problem. > Read up about the Unix/Linux file permissions system. You can't change > permissions of that directory and file e.g. via your FTP client, but > you can have your CGI script do it using the Perl chmod() function. I used chmod() immediately after creating the file. > If > you e.g. want anybody being able to read the file, you can set the > directory permission 755 and file permission 644. Hmmmm. I set both to 766 (if I recall correctly - it was a couple of months ago). I'll check up though and write another script to try and change the permissions as you suggest. > You can also have > the CGI script delete the file, since the user CGI is run as owns the > directory. The directory itself can well be deleted via your FTP > client, since *you* (I assume) own the directory in which the script > generated directory is located. Yes, it is my private cgi-bin. Thanks for your help. Ken Down -- ================ ARCHAEOLOGICAL DIGGINGS =============== | Australia's premiere archaeological magazine | | http://www.diggingsonline.com | ======================================== ================
Post Follow-up to this messageKendall K. Down wrote: > > Hmmmm. I set both to 766 (if I recall correctly - it was a couple of month s > ago). I'll check up though and write another script to try and change the > permissions as you suggest. Keep in mind that 755 and 644 (as decimal numbers) do not work: chmod 644,$filename; # Wrong You need 0755 or 0644: chmod 0644,$filename or warn "Can't chmod $filename: $!"; The leading zero tells perl that the literal that follows is a number in octal notation, which is what is needed for chmod(). -Joe
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.