Same problem I've been having for the week so far. My script makes directories but the problem is I can't make them so I can later remove the directories or even add things to them. I don't have permissions to use the folder my script just setup (even thought it's 0755). I've tried chowning using 1220 for my gid and uid but that didn't change the ownership of the directories either.

I could be doing it wrong I suppose so I posted the script below to see if anyone notices a bug pertaining to this problem. I know you're not likely to change ownership without being a superuser but 1220 is my account information so I don't see what's holding back.

Any advice?

#!/usr/bin/perl -w use strict; use diagnostics; use CGI qw(:standard); use POSIX; require SDBM_File; my $location = "stored.dbm"; my %stored; my @chars = ("a".."z","A".."Z"); my $chars; my $ID; my $uid = "1220"; my $gid = "1220"; chomp( my $user = param('user') ); chomp( my $pass = param('pass') ); tie %stored, 'SDBM_File', $location, O_CREAT | O_RDWR, 0644; print header, start_html('Log In'); print start_form(), table( Tr( td("Username"), ), Tr( td( textfield( -name => 'user', -size => 20 ), ) ), Tr( td("Password"), ), Tr( td( textfield( -name => 'pass', -size => 20 ), ) ) ), Tr( td(submit), ), end_form(); if ( param() ) { if (exists $stored{$user}) { print "User name already in use, please try another"; exit; } if (($pass) && ($user)) { $ID = join '', map { $chars[ rand @chars ] } 1..10; } my @combine = ($pass, $ID); $stored{$user} = join "::", @combine; print "random id was $ID<br>"; my $dir = $ENV{'DOCUMENT_ROOT'} . "/new/" . $ID; mkdir($dir, 0755); chown $uid, $gid, $dir; print "folder $dir was created"; print "<br>"; print "Test printing<br>"; foreach (sort keys(%stored)) { print "$_ => $stored{$_}<br>"; } }


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to File ownership by sulfericacid

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.