Hi!

I have a problem with changing file permissions with a perl/cgi script.

I uploaded a file ("testfile.txt") using FTP software.

I wanted to change that file permission from 644 to 777 with using a perl/cgi script. I didn't want to use FTP software or unix command promt, so I wrote a script which executes a command: chmod(0777,"testfile.txt"); But the chmod() function returns a 0 or "Operation not permitted" which means I can't change the permission.

I've read this somewhere:

> changing the permissions will probably not work, because the CGI script will run under the > webserver's user id, which is likely to be different from your user id.

I don't quite understand it, because I uploaded both, the script and the file I want to change permission, with the same password (ID).

What needs to be done to make this script work?

Regards,
Bostjan Kocan

Originally posted as a Categorized Question.


In reply to How do I execute chmod() the right way? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.