You are at a disadvantage, in that you are limited to the permissions of the UID under which your script runs. In addition to that, you probably aren't looking at the setting of umask for the UID, either. You can create a file, then change the ownership of it with the chown system call, which is documented alongside chmod.

The problem here is one of the permissions allotted to the UID under which the script runs. You probably do not have the permissions necessary to run chown. You should start by setting the umask to something like, well, 0. Read the manual page on it, either at perlfunc:umask or in the manual page for most shells that run on a UNIX system, as there is a command in these shells that manipulates the mask, as well. Odds are very good that your script is running in an environment where the umask has been set (probably in the server configuration) to a fairly restrictive default value.

--rjray


In reply to Re: create file - permission problems by rjray
in thread create file - permission problems by emilford

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.