Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

A bug in PERL or a bug in the server?

by DaWolf (Curate)
on Nov 20, 2000 at 17:13 UTC ( #42486=perlquestion: print w/replies, xml ) Need Help??
DaWolf has asked for the wisdom of the Perl Monks concerning the following question:

Hi again, folks.

I've made a script to automate the task of creating several subdirectories on the server. It looks into a txt file and for each line in there it creates the subdirectory named after the text of the line.

The command I've used to create it: chmod $dirN,0777;

Well, I've tested with only two lines/subdirectories to avoid making any "damage" to the server.

It created the two subdirectories, but the server - linux, of course ;) - doesn't recognizes the first one. I can't get into it, chmod it, delete it, rename it, anything at all... The second created directory was allright, I've even deleted it without any problems.

There aren't any differences between the name of the directorys - they're both "letters-only".

Does anyone have any ideas of what's happening here?

Er Galv„o Abbott
a.k.a. Lobo, DaWolf

Replies are listed 'Best First'.
Re: A bug in PERL or a bug in the server?
by snax (Hermit) on Nov 20, 2000 at 17:33 UTC
    chmod wants the mode (0777 in your example) first. Go read the docs on this one (follow the link).

Re: A bug in PERL or a bug in the server?
by rdw (Curate) on Nov 20, 2000 at 18:20 UTC

    Sounds to me like you've created a directory with a newline character ("\n") in it. You should use something like chomp to strip off the newline after you've read it in and before you give it to mkdir.

    It probably didn't happen with the second one because there wasn't a newline at the end of the text file.

    Have fun,


      Ahh, yes, that would make more sense -- the chmod command wouldn't be creating directories, would it?

      Anyway, to help you clean up what you've created, try to capture the directory name with a glob from the shell, like ls *dirname* to see if it will list it, then rm -ri *dirname* to delete it (substituting whatever glob you use to find the directory, naturally).

        Actually, I tried and failed to get my shell to let me delete a directory with a "\n" in it....

        ...but of course, since perl created the directory, it can remove it as well.

        DaWolf - it's probably easiest to just change the script to use rmdir to undo the 'damage' before you fix the chomp bug

        Have fun,


Re: A bug in PERL or a bug in the server?
by $code or die (Deacon) on Nov 21, 2000 at 00:10 UTC
    Just another point perhaps worth mentioning: Who has control over what is put in each text file?

    I.e. if you have users on your system that can create these files, then you have a potential security risk - it would be worth untainting or checking the files before running any system calls on it. Just a warning!
Re: A bug in PERL or a bug in the server?
by lolindrath (Scribe) on Nov 20, 2000 at 17:32 UTC
    It kind of sounds like your loop is skipping the first line of the text file. Try putting in a print statement and see how the loop behaves.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://42486]
Approved by root
[Corion]: (that module has been deprecated by its author already, so that's fair. Although I wonder why the backtracking can't be fixed to handle the formfeeds gracefully)
[choroba]: not enough tuits?
[Corion]: choroba: Yeah, maybe. I'm also unaware of who uses Email:: modules, but that's more my limited horizon of things ;)
[Corion]: Ah - there even is the replacement of Email::Address::XS , by the bug reporter, which hopefully fixes this bug already ;)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2018-06-20 12:00 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.