[25349] in Perl-Users-Digest
Perl-Users Digest, Issue: 7594 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 3 21:53:33 2005
Date: Mon, 3 Jan 2005 15:06:42 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Jan 2005 Volume: 10 Number: 7594
Today's topics:
can't get unlink to work on windows jan_buys@hotmail.com
Re: can't get unlink to work on windows <matternc@comcast.net>
Re: can't get unlink to work on windows <ThomasKratz@REMOVEwebCAPS.de>
Re: can't get unlink to work on windows jan_buys@hotmail.com
Re: can't get unlink to work on windows <ThomasKratz@REMOVEwebCAPS.de>
Re: can't get unlink to work on windows <noreply@gunnar.cc>
Re: can't get unlink to work on windows jan_buys@hotmail.com
Re: can't get unlink to work on windows <nobull@mail.com>
Re: can't get unlink to work on windows <jurgenex@hotmail.com>
Re: can't get unlink to work on windows jan_buys@hotmail.com
Re: can't get unlink to work on windows <mritty@gmail.com>
Re: can't get unlink to work on windows <sholden@flexal.cs.usyd.edu.au>
Re: can't get unlink to work on windows jan_buys@hotmail.com
Can't locate <module> in @INC - but I can see module is <justin@notospammms-oxford.com>
Re: Can't locate <module> in @INC - but I can see modul <x3v0-usenet@yahoo.com>
Re: Can't locate <module> in @INC - but I can see modul <justin@notospammms-oxford.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Dec 2004 08:29:34 -0800
From: jan_buys@hotmail.com
Subject: can't get unlink to work on windows
Message-Id: <1104337774.400343.117220@c13g2000cwb.googlegroups.com>
Hi,
Hope this is a quickie for you toughened perl gods.
I am using unlink in a CGI script (server currently running under my
own admin account) but I can't get it to remove a file with the unlink
command. The script should be cross-platform, so I can't use a system
command for this :
code :
$remfn = $FilePath.$PlatformSlash.$NFN;
my $cnt = unlink (qw|"$remfn"|); # db too
open (DEBUG, "> test.txt"); # db
print DEBUG "$remfn, $cnt, $!"; # db
close (DEBUG); # db
my debug file then shows :
c:\Program Files\Apache
Group\Apache\htdocs\noticeboard\uploads\UPL_8848.upl
, 0, No such file or directory
Which is strange, because the file IS there.
btw : tried these variants too :
unlink "$remfn";
unlink ("$remfn");
Thanks for any help !
------------------------------
Date: Wed, 29 Dec 2004 11:42:42 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: can't get unlink to work on windows
Message-Id: <pOadnfDpVuAfQ0_cRVn-ig@comcast.com>
jan_buys@hotmail.com wrote:
> Hi,
>
> Hope this is a quickie for you toughened perl gods.
>
> I am using unlink in a CGI script (server currently running under my
> own admin account) but I can't get it to remove a file with the unlink
> command. The script should be cross-platform, so I can't use a system
> command for this :
>
> code :
> $remfn = $FilePath.$PlatformSlash.$NFN;
> my $cnt = unlink (qw|"$remfn"|); # db too
> open (DEBUG, "> test.txt"); # db
> print DEBUG "$remfn, $cnt, $!"; # db
> close (DEBUG); # db
>
> my debug file then shows :
> c:\Program Files\Apache
> Group\Apache\htdocs\noticeboard\uploads\UPL_8848.upl
> , 0, No such file or directory
>
> Which is strange, because the file IS there.
>
> btw : tried these variants too :
> unlink "$remfn";
> unlink ("$remfn");
>
> Thanks for any help !
Are you word wrapping stuff? What you claim your debug file shows has line
feeds in it. Are they in the debug file? If they are, are they in the file
name? In particular, is it possible that $NFN has a trailing line feed as
your report from the debug file seems to show? Perhaps you need to chomp
$NFN after you get from wherever you get it from.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Wed, 29 Dec 2004 17:45:54 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: can't get unlink to work on windows
Message-Id: <41d2df42$0$776$bb690d87@news.main-rheiner.de>
jan_buys@hotmail.com wrote:
> Hi,
>
> Hope this is a quickie for you toughened perl gods.
>
> I am using unlink in a CGI script (server currently running under my
> own admin account) but I can't get it to remove a file with the unlink
> command. The script should be cross-platform, so I can't use a system
> command for this :
>
> code :
> $remfn = $FilePath.$PlatformSlash.$NFN;
> my $cnt = unlink (qw|"$remfn"|); # db too
> open (DEBUG, "> test.txt"); # db
> print DEBUG "$remfn, $cnt, $!"; # db
> close (DEBUG); # db
>
> my debug file then shows :
> c:\Program Files\Apache
> Group\Apache\htdocs\noticeboard\uploads\UPL_8848.upl
> , 0, No such file or directory
>
> Which is strange, because the file IS there.
Are you sure? I don't think the filename has newlines in it. Your debug
output does.
Do you read the paths and filenames from a file? Did you remove the
newlines after reading the lines from the file?
Many questions that could be answered easier had you shown a *short* but
*complete* script that produces the behaviour you mentioned. Please have a
look at the posting guidelines.
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
------------------------------
Date: 29 Dec 2004 09:03:11 -0800
From: jan_buys@hotmail.com
Subject: Re: can't get unlink to work on windows
Message-Id: <1104339791.690949.181590@f14g2000cwb.googlegroups.com>
Hi again,
Sorry for not posting a complete script. I can assure you that there
are no newlines within the pathnames. I create a small testscript that
still gives me the same problem :
#!c:\perl\bin\perl.exe
my $FilePath = 'c:\\Program Files\\Apache
Group\\Apache\\htdocs\\noticeboard\\uploads';
my $PlatformSlash = '\\';
$NFN = 'UPL_6229858.upl';
## start interpreting the request
use CGI qw/:standard :cgi-lib/;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
$remfn = $FilePath.$PlatformSlash.$NFN;
my $cnt = unlink (qw|"$remfn"|);
print "$remfn, $cnt, $!<br>";
This script will print to following to the browser screen :
c:\Program Files\Apache
Group\Apache\htdocs\noticeboard\uploads\UPL_6229858.upl, 0, No such
file or directory
(all on one line... google groups seems to add newlines)
When I go and look at the location of the files :
Microsoft Windows 2000 [versie 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
c:\Program Files\Apache Group\Apache\htdocs\noticeboard\uploads>ls
UPL_5328979.upl UPL_6229858.upl
c:\Program Files\Apache Group\Apache\htdocs\noticeboard\uploads>dir
Het volume in station C heeft geen naam.
Het volumenummer is 20A6-6074
Map van c:\Program Files\Apache
Group\Apache\htdocs\noticeboard\uploads
29/12/2004 17:59 <DIR> .
29/12/2004 17:59 <DIR> ..
29/12/2004 17:59 12.538 UPL_5328979.upl
29/12/2004 17:58 9.566 UPL_6229858.upl
2 bestand(en) 22.104 bytes
2 map(pen) 29.322.977.280 bytes beschikbaar
c:\Program Files\Apache Group\Apache\htdocs\noticeboard\uploads>
(sorry for the dutch version of windows :-) )
I am using ActivePerl 5.8.0, win32 btw...
------------------------------
Date: Wed, 29 Dec 2004 18:20:29 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: can't get unlink to work on windows
Message-Id: <41d2e75c$0$782$bb690d87@news.main-rheiner.de>
jan_buys@hotmail.com wrote:
> Hi again,
>
> Sorry for not posting a complete script. I can assure you that there
> are no newlines within the pathnames. I create a small testscript that
> still gives me the same problem :
>
> #!c:\perl\bin\perl.exe
> my $FilePath = 'c:\\Program Files\\Apache
> Group\\Apache\\htdocs\\noticeboard\\uploads';
> my $PlatformSlash = '\\';
Don't do that. If you want to be platform independent use File::Spec,
File::Basename and other Modules created for that purpose.
> $NFN = 'UPL_6229858.upl';
>
> ## start interpreting the request
>
> use CGI qw/:standard :cgi-lib/;
> use CGI::Carp qw(fatalsToBrowser);
>
> print "Content-type: text/html\n\n";
>
> $remfn = $FilePath.$PlatformSlash.$NFN;
> my $cnt = unlink (qw|"$remfn"|);
Ah, there it is! You try to unlink a file with double quotes around it.
This file does not exist. The double quotes are needed by the shell, not
by unlink.
Just use
my $cnt = unlink ($remfn);
instead.
> [rest snipped]
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
------------------------------
Date: Wed, 29 Dec 2004 18:16:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: can't get unlink to work on windows
Message-Id: <33g7okF3vsqsqU1@individual.net>
jan_buys@hotmail.com wrote:
> I am using unlink in a CGI script (server currently running under my
> own admin account) but I can't get it to remove a file with the unlink
> command.
<snip>
> my $cnt = unlink (qw|"$remfn"|); # db too
Please consider:
my $remfn = 'C:\somedir\UPL_8848.upl';
print qw|"$remfn"|, "\n";
Outputs:
"$remfn"
Not very surprising that your unlink command doesn't work, right? The
qw// operator is apparently not what you want. Try:
my $cnt = unlink $remfn;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 29 Dec 2004 09:48:42 -0800
From: jan_buys@hotmail.com
Subject: Re: can't get unlink to work on windows
Message-Id: <1104342522.828188.119570@c13g2000cwb.googlegroups.com>
Ah Thomas,
You made my day. Now it works indeed :-) Thanks a lot. I will go for
the filename modules approach as well. Quick and dirty WAS my name ;-)
Thanks to all for contributing.
------------------------------
Date: Wed, 29 Dec 2004 17:48:40 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: can't get unlink to work on windows
Message-Id: <cquqc6$s07$1@sun3.bham.ac.uk>
jan_buys@hotmail.com wrote:
> I am using unlink in a CGI script (server currently running under my
> own admin account) but I can't get it to remove a file with the unlink
> command. The script should be cross-platform, so I can't use a system
> command for this :
>
> code :
> $remfn = $FilePath.$PlatformSlash.$NFN;
> my $cnt = unlink (qw|"$remfn"|); # db too
This is trying to delete a file that actually has double quote
characters in its name.
I suspect you meant to say:
my $cnt = unlink ($remfn); # db too
Note it is unecessary to use the platform specific slash. You can
simply use '/'.
> open (DEBUG, "> test.txt"); # db
> print DEBUG "$remfn, $cnt, $!"; # db
> close (DEBUG); # db
>
> my debug file then shows :
> c:\Program Files\Apache
> Group\Apache\htdocs\noticeboard\uploads\UPL_8848.upl
> , 0, No such file or directory
>
> Which is strange, because the file IS there.
>
> btw : tried these variants too :
> unlink "$remfn";
> unlink ("$remfn");
Well, those two should work (but they are suboptimal (see FAQ: What's
wrong with always quoting "$vars"?)).
Do you get the same error?
Did you try from the command line instead of as a CGI script?
I think you may be able to get "No such file or directory" on Windows
when the real problem is permission denied on a parent directory
Are you sure the webserver is running under the admin account?
You how have any idea how bad an idea this is?
------------------------------
Date: Wed, 29 Dec 2004 17:59:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: can't get unlink to work on windows
Message-Id: <sgCAd.11916$tG3.10483@trnddc02>
jan_buys@hotmail.com wrote:
> Sorry for not posting a complete script. I can assure you that there
> are no newlines within the pathnames. I create a small testscript
> that still gives me the same problem :
>
> #!c:\perl\bin\perl.exe
> my $FilePath = 'c:\\Program Files\\Apache
> Group\\Apache\\htdocs\\noticeboard\\uploads';
Don't know what else is wrong with your script, but single quotes combined
with double backslash as path seperator is not going to work.
Use
- double quotes if you want "\\" interpolated into a single backslash
- or single backslash if you want a single backslash inside of single quotes
- or best of all: a single forward slash
jue
------------------------------
Date: 29 Dec 2004 10:01:31 -0800
From: jan_buys@hotmail.com
Subject: Re: can't get unlink to work on windows
Message-Id: <1104343291.273249.215640@z14g2000cwz.googlegroups.com>
Hi Brian,
The problem is solved now. Drop the quotes and it works indeed :-)
about the server running under the admin account : It should say 'my
test environment server is running under the admin account'. No
particle in my otherwise sane mind would think of doing that on a
production server machine ;-)
------------------------------
Date: Wed, 29 Dec 2004 18:24:23 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: can't get unlink to work on windows
Message-Id: <rDCAd.7471$sh5.2838@trndny08>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:sgCAd.11916$tG3.10483@trnddc02...
> jan_buys@hotmail.com wrote:
>
> > my $FilePath = 'c:\\Program Files\\Apache
> > Group\\Apache\\htdocs\\noticeboard\\uploads';
>
> Don't know what else is wrong with your script, but single quotes
combined
> with double backslash as path seperator is not going to work.
>
> Use
> - double quotes if you want "\\" interpolated into a single backslash
> - or single backslash if you want a single backslash inside of single
quotes
While true, the double backslash does indeed 'work'. Within single
quotes, a backslash will escape either a single quote or a backslash:
#!/usr/bin/perl
use strict;
use warnings;
my $foo = ' \\ ';
my $bar = ' \ ';
print "Foo: !$foo! Bar: !$bar!\n";
__END__
Foo: ! \ ! Bar: ! \ !
> - or best of all: a single forward slash
Paul Lalli
------------------------------
Date: 29 Dec 2004 19:42:19 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: can't get unlink to work on windows
Message-Id: <slrnct624r.dbb.sholden@flexal.cs.usyd.edu.au>
On 29 Dec 2004 10:01:31 -0800, jan_buys@hotmail.com wrote:
> Hi Brian,
>
> The problem is solved now. Drop the quotes and it works indeed :-)
>
> about the server running under the admin account : It should say 'my
> test environment server is running under the admin account'. No
> particle in my otherwise sane mind would think of doing that on a
> production server machine ;-)
Why dos you otherwise sane mind have such a large difference in
configuration of the production and test servers?
Doesn't that make life hard when putting something into production?
--
Sam Holden
------------------------------
Date: 29 Dec 2004 12:18:24 -0800
From: jan_buys@hotmail.com
Subject: Re: can't get unlink to work on windows
Message-Id: <1104351504.406604.102900@c13g2000cwb.googlegroups.com>
Sam Holden wrote:
> >
> > about the server running under the admin account : It should say
'my
> > test environment server is running under the admin account'. No
> > particle in my otherwise sane mind would think of doing that on a
> > production server machine ;-)
>
> Why dos you otherwise sane mind have such a large difference in
> configuration of the production and test servers?
>
> Doesn't that make life hard when putting something into production?
It's just the way I work. There are a billion of ways in which
security can be in the way for the script to work properly (and
security is a big word here). Just to separate the errors caused by
that from errors caused by improper Perling, I use a very open dev.
environment. Once things work there, I move to a strict environment,
knowing that if problems pop up there, they will be related to
permissions and nothing else.
Have a look over the newsgroups and count the number of people crying
about their broken script while they actually had a permissions problem
at hand.
It's just a way of working I like, not better than yours, but more
suitable to me ;-)
------------------------------
Date: Mon, 3 Jan 2005 18:39:41 -0000
From: "Justin Wyllie" <justin@notospammms-oxford.com>
Subject: Can't locate <module> in @INC - but I can see module is there!
Message-Id: <41d99186_1@mk-nntp-2.news.uk.tiscali.com>
Hi
I'm running a program sa-learn that comes with SpamAssassin anti-spam s/w.
This script fails on this line:
require Mail::SpamAssassin::CmdLearn;
with a message saying the module can't be found in @INC. The print-out for
@INC includes:
Can't locate Mail/SpamAssassin/CmdLearn.pm in @INC (@INC contains:
/usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd
/usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/5.6.1/i386-freebsd
/usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl)
and the module is installed in
usr/local/lib/perl5/site_perl/5.6.1/Mail/SpamAssassin/CmdLearn.pm
Is there any reason other than it not being there that a Perl require call
may fail?
Many thanks
Justin Wyllie
------------------------------
Date: Mon, 03 Jan 2005 14:59:58 -0500
From: Ken <x3v0-usenet@yahoo.com>
Subject: Re: Can't locate <module> in @INC - but I can see module is there!
Message-Id: <5vhCd.956$7k5.797@fe37.usenetserver.com>
Justin Wyllie wrote:
> Hi
>
> I'm running a program sa-learn that comes with SpamAssassin anti-spam s/w.
>
> This script fails on this line:
>
> require Mail::SpamAssassin::CmdLearn;
>
> with a message saying the module can't be found in @INC. The print-out for
> @INC includes:
>
>
> Can't locate Mail/SpamAssassin/CmdLearn.pm in @INC (@INC contains:
> /usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd
> /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/5.6.1/i386-freebsd
> /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
> /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl)
>
> and the module is installed in
> usr/local/lib/perl5/site_perl/5.6.1/Mail/SpamAssassin/CmdLearn.pm
>
> Is there any reason other than it not being there that a Perl require call
> may fail?
>
> Many thanks
>
> Justin Wyllie
>
>
Justin,
Any reason you are using a 'require' instead of 'use'? I think 'use'
would probably solve your problem.
Otherwise, from looking at the error message, it looks like it may be a
path problem.
It says INC contains '/usr/local/lib/perl5/site_perl/5.6.1'. But, it is
trying to require 'Mail/SpamAssassin/CmdLearn.pm'. There is a missing /
between the library path and the module.
(It is looking for
'/usr/local/lib/perl5/site_perl/5.6.1Mail/SpamAssassin/CmdLearn.pm',
which doesn't exist.)
- Ken
------------------------------
Date: Mon, 3 Jan 2005 21:39:31 -0000
From: "Justin Wyllie" <justin@notospammms-oxford.com>
Subject: Re: Can't locate <module> in @INC - but I can see module is there!
Message-Id: <41d9bba9_3@mk-nntp-2.news.uk.tiscali.com>
>
> Justin,
>
> Any reason you are using a 'require' instead of 'use'? I think 'use'
> would probably solve your problem.
>
> Otherwise, from looking at the error message, it looks like it may be a
> path problem.
>
> It says INC contains '/usr/local/lib/perl5/site_perl/5.6.1'. But, it is
> trying to require 'Mail/SpamAssassin/CmdLearn.pm'. There is a missing /
> between the library path and the module.
>
> (It is looking for
> '/usr/local/lib/perl5/site_perl/5.6.1Mail/SpamAssassin/CmdLearn.pm',
> which doesn't exist.)
>
> - Ken
>
Hi Ken
Thanks for your reply. In fact after a bit more fiddling about I found the
problem was that the paths in my @INC are all relavtive to my chrooted jail
and I needed to put the full system path into @INC. Thanks for the
encouragement though
Justin
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7594
***************************************