in reply to Handling returns from mkdir.
mkdir does not give any standard output. In case of failure of mkdir you see the error output which is not returned by backtick (``) operators. You may have to redirect error output to standard output to capture it.
my $op = `mkdir winlog 2>&1`;On my system the error message in case of pre-existence of directory is "cannot create directory `winlog': File exists" which will fail your regular expression. I think using the return codes is a better idea than using the error output. You can get the return code in $?
For all codes returned by the mkdir check the detailed manual of the command
Update: As pointed by corion and marto below mkdir of perl is the correct option. My answer is more concerned with the way of getting output rather than the approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Handling returns from mkdir.
by marto (Cardinal) on Dec 24, 2010 at 09:24 UTC | |
by samarzone (Pilgrim) on Dec 24, 2010 at 09:32 UTC | |
by dannyd (Sexton) on Dec 24, 2010 at 10:59 UTC | |
by ikegami (Patriarch) on Dec 24, 2010 at 15:27 UTC |