CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
WinXp Command Line Suppress Output

 



yabo
New User

Jan 20, 2009, 6:55 AM

Post #1 of 3 (819 views)
WinXp Command Line Suppress Output Can't Post

First post here...

I'm trying to use mkdir in a loop. It often comes across the same directory to make, which of course triggers an "already exists" message from command line and doesn't make the directory. This is fine, and works as I wish, but I would like to hidethe already exists message output. Windows Xp does not have any quiet paramter that hides this type of message.

I tried doing $returnedlines = `mkdir <directory>` which works in cygwin but not at command line.

Changes to the system are not permitted as this will be run on many users machines.

Thanks


FishMonger
Veteran / Moderator

Jan 20, 2009, 7:03 AM

Post #2 of 3 (818 views)
Re: [yabo] WinXp Command Line Suppress Output [In reply to] Can't Post

Perl has a built-in mkdir command which does what you need and is more efficient than spawning a new process via backticks.


Code
C:\>perldoc -f mkdir 
mkdir FILENAME,MASK
mkdir FILENAME
mkdir Creates the directory specified by FILENAME, with permissions
specified by MASK (as modified by "umask"). If it succeeds it
returns true, otherwise it returns false and sets $! (errno). If
omitted, MASK defaults to 0777. If omitted, FILENAME defaults to
$_.

In general, it is better to create directories with permissive
MASK, and let the user modify that with their "umask", than it
is to supply a restrictive MASK and give the user no way to be
more permissive. The exceptions to this rule are when the file
or directory should be kept private (mail files, for instance).
The perlfunc(1) entry on "umask" discusses the choice of MASK in
more detail.

Note that according to the POSIX 1003.1-1996 the FILENAME may
have any number of trailing slashes. Some operating and
filesystems do not get this right, so Perl automatically removes
all trailing slashes to keep everyone happy.

In order to recursively create a directory structure look at the
"mkpath" function of the File::Path module.



yabo
New User

Jan 20, 2009, 7:12 AM

Post #3 of 3 (816 views)
Re: [FishMonger] WinXp Command Line Suppress Output [In reply to] Can't Post

Forgot about that, thanks. Worked nicely.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives