Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading folder content and permissions

Status
Not open for further replies.

pablo1999

IS-IT--Management
Jan 17, 2005
15
0
0
US
I want to tweak a small program I'm creating. It will read a directory and if it finds a file inside the directory with an executable it should do something.

I just pasted here the section that matters to the program where I'm trying to detect if its executable.

Thanks for the assistance.


while (my $name = readdir DIR) {
next if $name =~ /^\./;

if (-x $name)
{
#do something
}

}
 
did you do a opendir?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Yes, I'm using opendir. I just pasted the part that matters of the script where I need to specifiy how to find out if the file I'm reading from the folder is executable.
 
If you are on Windows I don' think -x works properly, maybe someone can confirm that. If you are not on Windows and the code you posted is not working you have to use the full path to the file you are testing with -x or chdir() into the directory where the files are.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top