Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Handling returns from mkdir.

by dannyd (Sexton)
on Dec 24, 2010 at 10:07 UTC ( [id://879011]=note: print w/replies, xml ) Need Help??


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". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found