Reputation: 7087
/tmp
of course exist, but mkdir -p
shouldn't return an error when a directory exist.
So why does the following fail?
system("/usr/bin/mkdir -p /tmp 2> /dev/null") == 0 or print("Failed");
if ($?) {print("Failed");}
system("/usr/bin/mkdir -p /tmp 2> /dev/null");
if ($?) {print("Failed");}
From Bash I get the expected 0
# mkdir -p /tmp
# echo $?
0
Upvotes: 3
Views: 142
Reputation: 249093
It's /bin/mkdir
not /usr/bin/mkdir
. I know this not only because you said /usr/bin/mkdir
fails and not only because I looked on my (Mac OS X) system, but also because such low-level, fundamental programs are often in /bin
because they are required to boot a system etc.
By the way, you should not use system(mkdir)
to make directories from Perl. I'm sure there are plenty of ways to do it more "natively" and with better error checking.
Upvotes: 3