hi, I have the following error on a win server:
"Invalid Top Directory perl/lib/file/find.pm line 598
Here's the code and I'll explain what I found until now: - #!/usr/bin/perl
-
#
-
use strict;
-
use warnings;
-
use File::Find;
-
use MSDOS::Attrib qw(get_attribs set_attribs);
-
-
(my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my $yday, my $isdst)=localtime(time);
-
$year = $year + 1900; # $year 0 = real year 1900
-
$mon = $mon + 1; # $month 0 = January
-
-
open(LOG, ">>./atd_files_$year-$mon-$mday\.txt") or die "Can't open LOG: $!";
-
print LOG ("\n***************************************** NEW LAUNCH *****************************************\n") or die "Can't write to LOG: $!";;
-
printf LOG " Script started at:\n %4d-%02d-%02d %02d:%02d:%02d\n\n", $year,$mon,$mday,$hour,$min,$sec or die "Can't write to LOG: $!";
-
-
my $homedir = "E:/test_dir";
-
opendir (IMD, $homedir) or die "Couldn't find dir: IMD ($!)";
-
my @thefiles= readdir(IMD);
-
closedir(IMD);
-
-
my @dirs;
-
my $x=0;
-
my $n = 0;
-
-
foreach my $f (@thefiles){
-
if (-d $f && $f !~ /^\.+/){
-
print "$f\n";
-
$dirs[$x]=$f;
-
$x++;
-
}
-
}
-
-
#print "@dirs\n";
-
find(\&wanted, @dirs);
-
-
sub wanted {
-
if (/Project\.atd/){
-
my $attrib = get_attribs($File::Find::name);
-
if ( $attrib =~ /.H.+/){
-
$n++;
-
print "$File::Find::name\n";
-
}
-
}
-
}
-
-
print ("\n\nTotal: $n files\n");
-
-
print ("\a");
-
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=localtime(time);
-
printf LOG "\n\n Script ended at:\n %4d-%02d-%02d %02d:%02d:%02d\n", $year+1900,$mon+1,$mday,$hour,$min,$sec or die "Can't write to LOG: $!";
-
print LOG ("\n***************************************** END LAUNCH *****************************************\n") or die "Can't write to LOG: $!";
So, the problem is the $homedir
If I put "c:/blabla/blibli" as homedir, everything's ok.
I tested the same script on a 2000pro with "c:/balbla" and "d:/blabla" everything's ok.
But as soon as I put "E:/blabla" on the server, I got the error. Tested with different directories on E:, everytime I got an error. Not on C: or D:
anyone got an idea? (is it a bad thing to edit with Windows Notepad?? I usually use Jext)
Additional info:
I also got the error with
C:/ ; C:/ADMIN but not with C:/ADMIN/Analyst_Project atd_RightsHidde n
I'm totally lost now!!
11 7431
Another edit:
on my local machine, where everything was working, it didn't worked with
$homedir = "c:/" or eany other dir
But it works with $homedir = "c:"
Ok, well, I found another error in my script..
¨$homedir is not working at all.. except if $homedir = the directory where the script is located, then the script functions.
I also noticed a problem with Attrib..
When I do a print $attrib after the getattrib, it displays nothing :s
Another edit:
But it works with $homedir = "c:" (well, it doesn't work properly but it doesn't give an error)
I made a check: 15 target files, non hidden, all in log. Changed 1 to hidden.
The log still lists 15 files.
Could be two reasons:
- attrib function is not working properly
- the hidden attribute "H" is not in the second place as I saw on a site. But print $attrib should at least return something in stead of nothing..
I'm completely lost now.. Just a beginner, so maybe I use Find::File and MSDOS::Atrib wrong?? If you need more info, don't hesitate!
Update: (sorry about all those updates, but I continue searching)
about attrib..: attrib is working properly
it should be this: - my $myfile = "$homedir/$File::Find::name";
-
my $attrib = get_attribs($myfile);
so, the only question left is the File::Find error (as stated in the subject ^^ )
RonB 589
Recognized Expert Moderator Contributor
Your posts are all over the map with what is or isn't working and no detail on what changes you made to the script between those posts.
There are a number of problems with your script, but we'll start out with the"Invalid Top Directory" error.
Which var is it working on when you receive this error and exactly what is the value of that var?
Have you checked that the value it's referring to is actually a directory and that you have proper permissions to access that directory?
(If I could edit my posts after an hour, there wouldn't be 4 posts ^^)
So, every change I made has been detailed (changes of the $homedir var and changes of the Attrib part). I don't see what I forgot?
The value I'm working on for $homedir is actually a directory (not a mapped drive) and permissions have been set. I posted what worked and what not, and the reason I think why (may be completely wrong). What I understood so far is that the script is only working if the script is in the same directory as $homedir.
I never worked with File::Find before and it's a quite complete module and I just tried to understand what i needed to.
If you need any other info, shoot. I'm glad that someone who has the knowledge can show me the way.
RonB 589
Recognized Expert Moderator Contributor
Lets start at the beginning and clean up the script.
Add this to the list of modules to load.
Change this: - (my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my $yday, my $isdst)=localtime(time);
-
$year = $year + 1900; # $year 0 = real year 1900
-
$mon = $mon + 1; # $month 0 = January
-
-
open(LOG, ">>./atd_files_$year-$mon-$mday\.txt") or die "Can't open LOG: $!";
-
print LOG ("\n***************************************** NEW LAUNCH *****************************************\n") or die "Can't write to LOG: $!";;
-
printf LOG " Script started at:\n %4d-%02d-%02d %02d:%02d:%02d\n\n", $year,$mon,$mday,$hour,$min,$sec or die "Can't write to LOG: $!";
-
To this: -
my $logfile = strftime("atd_files_%Y-%m-%d.txt", localtime);
-
open my $LOG, '>>', $logfile or die "Can't open <$logfile> $!";
-
-
print $LOG "\n", '*' x 25, ' NEW LAUNCH ', '*' x 25, "\n";
Get rid of this unnecessary and inefficient code (which is the source of your problem). -
opendir (IMD, $homedir) or die "Couldn't find dir: IMD ($!)";
-
my @thefiles= readdir(IMD);
-
closedir(IMD);
-
-
my @dirs;
-
my $x=0;
-
my $n = 0;
-
-
foreach my $f (@thefiles){
-
if (-d $f && $f !~ /^\.+/){
-
print "$f\n";
-
$dirs[$x]=$f;
-
$x++;
-
}
-
}
And change your call to the find function to this: - find(\&wanted, $homedir);
Change this: -
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=localtime(time);
-
printf LOG "\n\n Script ended at:\n %4d-%02d-%02d %02d:%02d:%02d\n", $year+1900,$mon+1,$mday,$hour,$min,$sec or die "Can't write to LOG: $!";
-
print LOG ("\n***************************************** END LAUNCH *****************************************\n") or die "Can't write to LOG: $!";
To this: - print $LOG strftime("\n\n Script ended at:\n %Y-%m-%d %H:%M:%S\n", localtime),
-
"\n", '*' x 25, ' END LAUNCH ', '*' x 25, "\n";
Well, all I have to say is .. thank you very much!!!!
It works great and the script is 2x smaller.
And POSIX strftime is easier to work with than the other one.
And I also learned new things about logging and the print command!
Thanks again!!! This is what I call a great answer to a problem ^^
RonB 589
Recognized Expert Moderator Contributor @ezechiel
You're welcome.
The wanted sub could be cleaned up a little, but it's not too bad, so I left it alone.
But if you're interested, here's the cleaned up version. - sub wanted {
-
return unless /Project\.atd/;
-
-
my $hidden = substr(get_attribs($File::Find::name), 1, 1);
-
-
if( $hidden eq 'H' ) {
-
$n++;
-
print "$File::Find::name\n";
-
}
-
}
ok, thanks for the info. I'll check out the substr() function.
About this one: - open my $LOG, '>>', $logfile or die "Can't open <$logfile> $!";
Don't I need to close the log at the end? I suppose it is like this?: Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joe Hershman |
last post by:
all,
not sure what the best place to post this one, hopefully someone can help
because this is a real show stopper. i am getting the error shown below
when i try to build a deployment project. all the projects build fine, but
when vs.net starts to create the msi the error occurs.
i am seeing this same (the file sometimes differs) error on two different
machines so i don't think it is related to the computer. i have uninstalled...
|
by: Brian Fulford |
last post by:
I am trying to deploy a web app with a deployment project since I am
including Crystal Reports for .Net.
I attached all the merge modules, etc but I am getting a build error when I
try to build the setup project.
Could not find file 'C;\Web\ccsm\ccsm_search.aspx' 'Interface not
registered'
Thie file is included in the project, so I am not sure what is going on!!
|
by: jlacefie |
last post by:
Hello,
I am having trouble with the following code using ASP.Net 2.0. I
recieve an error on the line File.OpenRead(fPath) stating could not
find file . The fPath comes from a textbox control on the client and
the error displays the correct path for the file. This code works
when I use the browser on the server that is hosting the site, but it
does not work when I access this site on any other machine. Does the
OpenRead only work on...
|
by: dereski |
last post by:
Hey all,
I am trying to connect to my database but I am getting error "80004005 Could Not Find File" Any Ideas as to why? I tried recreating the database again, just in case it was corrupted but same result. I am using VBA
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=N:\new parcel\WawaDogs;"
'Open the connection
MyConn.Open
|
by: Amritha.Datta |
last post by:
Can anyone tell me why the below code returns error?
Exception Details: System.IO.FileNotFoundException: Could not find
file
Dim strLFolder As String = "c:\Temp\F Files"
Dim intClientID As Integer = 1221
Dim XMLStr As String = strLFolder & "\" &
intClientID.ToString.Trim & "\Lk\HeaderTrailerDeltails_data.xml"
Dim dsPubs As New DataSet
| |
by: jjlagtap |
last post by:
Hey everyone
When I try to open a file i get the Exception listed below. The weird thing is it works when I run the web app locally and when i use a remote server and open a file on my computer. When someone else uses the web app and tries to open a file using the remote server the error below happens.
any help?
**Code**
C# - filepath is a valid file name which is passed via the form.
System.IO.BinaryReader br = new...
|
by: chandan |
last post by:
Hi All,
I am creating a web setup Project using VS 2005.First time its works
fine, But when I closed the solution and again open solution and try
to build web setup project then there is an error like that could not
find file (.msi,.exe,.tmp) with these extension inside the debug or
release folder of the web setup Project.
I am not able to find where is the problem, some times its
works and sometime raises error for cannot find file....
|
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= |
last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an
error: Could not find file 'C:\testfile.xls'.
If I add the file (c:\testfile.xls) to the server I do not get the error and
the file is copied from the server to the server, rather than from the web
client to the server.
Please help!!!
|
by: JustRun |
last post by:
I have two windows application projects in the same solution, The solution contains an application that has a reference to another application in the same solution,
When I tried to publish the project that contains the reference it gave me that error :
Error 8 :Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0
And another question:
If I will use the project 1 with all my project is it correct to make...
|
by: JustRun |
last post by:
Hi All
This is a very urget, Plz answer me
I have two windows application projects in the same solution, The solution contains an application that has a reference to another application in the same solution,
When I tried to publish the project that contains the reference it gave me that error :
Error 8 :Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |