in reply to Re: Handling returns from mkdir.
in thread Handling returns from mkdir.

Thanks for the help (Im trying to keep this code same for linux and windows, so im scared to use any options)

my $err = `mkdir $FolderName 2>&1`; chomp ($err); if ($? != 0) { if ($? == 256) { print "Warning : $err"; } else { print "Error : $err"; } }

That part of the code now works like a charm :)

Replies are listed 'Best First'.
Re^3: Handling returns from mkdir.
by afoken (Chancellor) on Dec 24, 2010 at 11:36 UTC
    Im trying to keep this code same for linux and windows, so im scared to use any options

    One more reason NOT to use an external mkdir. Perl's builtin function works the same everywhere. "2>&1" doesn't work on all Windows versions, so you can't use it according to your rules. $FolderName is not quoted properly, this will bite you soon. Remember that you need to quote differently on Windows and Linux, because you have different shells. Don't think that quoting rules are the same for all shells that you might see on Linux. bash is the most common shell on Linux, but it's not the only one.

    Short: Use the buildin mkdir function. It is faster, cleaner, and opens no security holes.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)