Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Dir Create

by rawsr71 (Novice)
on Aug 22, 2007 at 15:31 UTC ( [id://634395]=perlquestion: print w/replies, xml ) Need Help??

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

I have an automation script that, among other things, creates directories and tosses files in them. It works fine on 3 machines but fails to create the directories on two others and I haven't a clue why. I've done it with both the native mkdir and the system mkdir call. Neither works on the two other machines. We're all running the same OS (WinXP). I can run on my machine against their work and it's fine so it's not a fluky name issue. Doesn't matter if the mkdir is running on their own machine or a server so it's not a permissions problem. (it fails if I log onto their machine and run it) Here's a couple lines from the script that both fail (or is it something in their OS?). Oh and the variables are setting properly when printed to the screen.
#
else { system ("mkdir", "C:\\automation");
#
system ("mkdir", "$bomdir\\$bomfoldname");

Any help would be appreciated. Thank you.

Replies are listed 'Best First'.
Re: Dir Create
by ikegami (Patriarch) on Aug 22, 2007 at 15:35 UTC

    "Neither works" is not very descriptive. What's the error message?

    mkdir("c:\\automation") or die("Unable to create automation directory: $!\n");

    Update: Not that if you want to create multiple levels at once, you'll need mkpath from core module File::Path:

    use File::Path qw( mkpath ); eval { mkpath("c:\\nonexistant\\automation"); }; if ($@) { die("Unable to create automation directory: $@\n"); }
Re: Dir Create
by Taulmarill (Deacon) on Aug 22, 2007 at 15:42 UTC
    You may want to check if your script runs with permission to create that directory. Also you may want to show us some error messages. perldoc -f system should give you some idea how to display them.
Re: Dir Create
by ww (Archbishop) on Aug 22, 2007 at 18:44 UTC
    In a word, as previous responders noted, "permissions."

    Now what I hope may offer some added value, rather than a mere echo:

    I have observed (at least in several governmental organizations I'm familiar with) windoze admins do their setups with a default !allowed for file or dir creation in the root. My impression is that they're trying to force users to confine their writes to "Documents and Settings"\usename in some misguided attempt at "enhancing security."

    Sometimes, they get carried away with this kind of procedure and apply it where it shouldn't be applied.

      Thank you all for your responses. The individuals involved can manually create the folders so it's not permissions. And both are out of the office today or I would have attempted the better error messages. Previously I wasn't getting any error at all, even under the verbose script running. I'll try the mkpath idea, it sounds better anyway. ;-) Thanks again!
        mkpath worked. Now I have to figure out why they can't get code from VSS when the others can. Thank you everyone!
Re: Dir Create
by kinnerc (Initiate) on Aug 22, 2007 at 15:35 UTC
    The first thing that comes to mind is something rather simple: do you have the needed rights to create directories and folders on the machine where your script is not working?
    -- Doc Kinne, KQR
    American Association of Variable Star Observers

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-28 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found