Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

directory handling on NT

Posted on 1998-10-01
8
Medium Priority
?
150 Views
Last Modified: 2010-03-05
2 questions:
first, how do you determine the existance of a named directory on NT?  -e $fn doesn't work.
second, can mkdir() or another method be used to create a directory other than in the current one (like a\b\c for example)?
0
Comment
Question by:glow060197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:b2pi
ID: 1205069
I don't believe either of these is NT specific

-d will tell you if a directory exists, or if a file is a directory
(note that even on unix, -f $dir will return false if $dir is a
directory).

mkdir(/this/is/an/odd/path) will work if /this/is/an/odd is a
directory, or, you can use

use File::Path;
mkpath('/this/is/an/odd/path',0,777);

which will make whatever part of the path needs to be made.


0
 

Author Comment

by:glow060197
ID: 1205070
actually on NT to get directory entry attributes (e.g. file ? directory? hidden? ...) you must use Win32::File::getAttributes()  or something similar (i'm away from my notes..) but that doesn't allow for checking *existence* which is what i'm looking for.  you're halfway there..i'll give you the points if you get this.  thanks.  

what i don't understand is why they couldn't have made the -x type commands work on NT if you can do it anyways.  is the Win32 library ("module") somehow "non-standard", or what?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205071
Have you actually TRIED using -d?  Or are you using ActiveWare?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:glow060197
ID: 1205072
actually I am using ActiveWare...I don't know any better to use.
I actually tried using -f and -d though.  what perl should i obtain?  does gnu have one for Windows?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205073
Yup.  If you download the standard distribution, it compiles fine, and
(I believe) standard file operators work.
0
 

Author Comment

by:glow060197
ID: 1205074
alright.  if you want the points, though you need to submit another 'answer'.  
thanks a lot.
0
 
LVL 5

Accepted Solution

by:
b2pi earned 300 total points
ID: 1205075
You are sure that the code

if (-f '/temp') {
   print "How did I get here?\n";
} else {
   print "Yup, -f returns 0 on directories\n";
}

if (-d '/temp') {
    print "Yup, -d does work\n";
} else {
    print "Oh, no, Mr. Bill!!!\n";
}



doesn't do what it should on active ware?
0
 

Author Comment

by:glow060197
ID: 1205076
those commands didn't seem to work, no.  but i'll try your code tomorrow and see how it does.

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question