Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

File creation script

by ibaboom (Initiate)
on May 28, 2008 at 18:51 UTC ( #688903=perlquestion: print w/replies, xml ) Need Help??

ibaboom has asked for the wisdom of the Perl Monks concerning the following question:

Good day. I have a file, I want to create directories only on a new file system with the same owners and group names.

so I have a input file that looks like:
____________________ # file: /filename/ # owner: me # group: group user::rwx ser:uid:rwx group::r-- # file: /filename/ # owner: you # group: yourgroup user::rwx ser:uid:rwx group::r-- __________________
I have figured out how to print directories and in reading the Cammel book 'Programming Perl' it says to put all of the variables into an array to save from making a lot of threads to the mkdir call. Not really sure how to do something like that. Thanks a lot A

Replies are listed 'Best First'.
Re: File creation script
by pc88mxer (Vicar) on May 28, 2008 at 19:16 UTC
    According to the setacl man page you can put the acl specification in a file, and its syntax is exactly what getacl produces. So, try this:
    local($/) = "\n\n"; while (<>) { # read one acl stanza at a time open(TEMP, ">/tmp/acl"); print TEMP; close(TEMP); # Determine $filename from $_ if (m/^# file:\s*(.*)/m) { my $filename = $1; system("setacl", "-f", "/tmp/acl", "-r", "-s", $filename); } else { warn "unable to determine target filename in:\n$_\n"; } }
Re: File creation script
by jethro (Monsignor) on May 28, 2008 at 21:22 UTC
    If I get you right, you want to find out whether a file is a directory or just a file.

    That is quite easy:

    if (-d $filename) { ... }
    More info about file tests like -d can be found in the perlfunc man page around line 147, at the beginning of the alphabetical listing of the functions
Re: File creation script
by jethro (Monsignor) on May 28, 2008 at 19:23 UTC
    You should have looked at the preview of your question. As it stands it needs too much time to comprehend (for me at least).

    Could you please post your question again, better formatted this time. Please use the code-tag. Please read the helpfull information on the posting page.

Re: File creation script
by apl (Monsignor) on May 28, 2008 at 19:29 UTC
    In addition to what jethro said, could you give an example of what ti is you wish to see as the result? I don't understand what how can I make the program ommit actual file names means.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://688903]
Approved by pc88mxer
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2022-08-14 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?