Unlink Not Working On Windows Server 
Author Message
 Unlink Not Working On Windows Server

Greetings All;

I am running a flattext database allowing a client to enter properties for
sale (actually I inherited it). An HTML form allows them the interface and
currently allows:

- new record entry (list a new property for sale)
- edit record entry (edit an existing property's text)

Recently I was asked to write some script to allow them to upload additional
pictures for their properties besides the main property picture so that they
could link text in the descriptions to it. So for example if the text
description says "You will love this new home with spa, pool, and large
living room" then the words "spa", "pool", and "large living room" will link
to pictures of those items. The new functions works so the app now allows:

- new record entry
- edit record entry
- add additional pictures

The problem is deleting old image files for properties that have been sold.
All images are in one directory on the web servers - a Windows2000 web
server at "/images/houseimages/", but the script does not delete files,
rather I get an HTTP 500 error:

====================

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.

of the time the error occurred, and anything you might have done that may
have caused the error.

More information about this error may be available in the server error log."

 ====================

The script is passed "imageFile=imagename.ext" from its calling form and
here is the perl script I am having problems with:

===========copy perl script=======
#!/usr/bin/perl

## USEFUL DEBUG: RETURNS BLANK PAGE IF SCRIPT REACHED
#BEGIN {
#print "Status: 200 OK\nContent-Type: text/html\n\n";
#}
## END USEFUL DEBUG

use CGI;
$cgi=new CGI;

my $filename = $cgi->param('imageFile');
my $delPath =
"/home/httpd/vhosts/thewebsite.com/httpdocs/datafiles/houseimages/"
# Do some sanity / untaint checks on $filename

# chdir ($delPath) or die "Can't move to images dir: $!";
# unlink $filename or die "Can't delete $filename: $!";

unlink($delPath$filename);

print $cgi->header();
print $cgi->start_html;
print <<HTML;
<p>
File Deleted Successfully!<br>
File name : $filename<br>
Store Path : $delPath<br>
</p>
HTML
print $cgi->end_html;
exit;

===========end copy perl script=======

I have tried two separate types of unlinks coded above, and the one that is
remarked out did not produce any error messages :

# chdir ($delPath) or die "Can't move to images dir: $!";
# unlink $filename or die "Can't delete $filename: $!";

When I uncomment the "Useful Debug" section it produces a nice blank page,
so I am not sure why the unlink portion is not working. If the problem was
with my $delpath specification I would expect a different error, and I have
tried different forms of the path that is there.

Anyone with any ideas why this does not work?

-George

georgeconklin AT comcast DOT net



Sat, 01 Oct 2005 19:13:48 GMT  
 Unlink Not Working On Windows Server

Quote:

> rather I get an HTTP 500 error:
> "Internal Server Error

[snip]

Quote:
> More information about this error may be available in the server error log."

What messages did you see when you looked at the server error log?

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sat, 01 Oct 2005 21:01:04 GMT  
 Unlink Not Working On Windows Server
Hi Tad;

I do not know, though I have placed a call to the hosting company to find
out. I sort of hoped that even though Perl is supposed to transcend the
platforms upon which it is installed there would be a common, well-known
problem using Perl's unlink. I will get back here with the error log entry
ASAP.

-George


Quote:

> > rather I get an HTTP 500 error:

> > "Internal Server Error

> [snip]

> > More information about this error may be available in the server error
log."

> What messages did you see when you looked at the server error log?

> --
>     Tad McClellan                          SGML consulting

>     Fort Worth, Texas



Sat, 01 Oct 2005 20:52:22 GMT  
 Unlink Not Working On Windows Server

[ Please do not top-post again.
  Text rearranged into a sensible order.
]

Quote:




>> > rather I get an HTTP 500 error:

>> > "Internal Server Error

>> [snip]

>> > More information about this error may be available in the server error
> log."

>> What messages did you see when you looked at the server error log?
> I do not know, though I have placed a call to the hosting company to find
> out.

OK, then what happens when you run the program from the command
line rather than as a CGI program?

Quote:
> I sort of hoped that even though Perl is supposed to transcend the
> platforms upon which it is installed there would be a common, well-known
> problem using Perl's unlink.

Yes, there is such a well-known problem.

Permissions.

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 02 Oct 2005 01:31:09 GMT  
 Unlink Not Working On Windows Server

Quote:

> the script does not delete files,
> unlink($delPath$filename);

If you want to know why the unlink() failed, then you should
ask why the unlink failed by testing its return value and
outputting the $! variable's contents:

   unlink($delPath$filename) or die "could not unlink:  $!";

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 02 Oct 2005 01:33:36 GMT  
 Unlink Not Working On Windows Server
On Tue, 15 Apr 2003 14:13:48 -0400, "George"

Quote:

>use CGI;

It might be helpful to add this:

use CGI::Carp qw/fatalsToBrowser/;

Quote:
>unlink($delPath$filename);

And, as Tad said:

unlink($delPath$filename)  or die "Can't delete $filename: $!;

Phil
--
Ignore coming events if you wish to send me e-mail



Sun, 02 Oct 2005 08:03:39 GMT  
 Unlink Not Working On Windows Server

Quote:

> unlink($delPath$filename);

There is a syntax error there by the way...

You could have found that by testing from the command line with:

   perl -cw someprog.cgi

You probably want one of these instead:

   unlink( "$delPath$filename" ) or die ...
or
   unlink( "$delPath/$filename" ) or die ...
or
   unlink( $delPath . $filename ) or die ...

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 02 Oct 2005 15:40:32 GMT  
 Unlink Not Working On Windows Server

Quote:

> > unlink($delPath$filename);

> There is a syntax error there by the way...

> You could have found that by testing from the command line with:

>    perl -cw someprog.cgi

> You probably want one of these instead:

>    unlink( "$delPath$filename" ) or die ...
> or
>    unlink( "$delPath/$filename" ) or die ...
> or
>    unlink( $delPath . $filename ) or die ...

> --
>     Tad McClellan                          SGML consulting

>     Fort Worth, Texas

As I mentioned in my original post I have tried "....die..."  including the
$! and it did not work. I do not have access to the command line so far as I
know (Telnet?). I tried the lines below one at a time and only got an HTTP
500 "Internal Server Error" :

unlink( "$delPath$filename" ) or die "could not unlink: $!";
unlink( "$delPath/$filename" ) or die "could not unlink: $!";
unlink( $delPath . $filename ) or die "could not unlink: $!";
unlink( "$delPath . $filename" ) or die "could not unlink: $!";

The path to the sample file I am trrying to unlink is
"/home/httpd/vhosts/thewebsite.com/httpdocs/datafiles/houseimages/".  The
path to the perl script is
"/home/httpd/vhosts/thewebsite.com/httpdocs/cgi-bin". Permissions are noted
below:

/home - unknown
/httpd - 755
/cgi-bin - 755
/datafiles - 755
/houseimages - 755
my perl script - 755

George Conklin
Divergent Web Design
geo AT divergentweb DOT com
"Insert witty quotation here."



Thu, 06 Oct 2005 07:01:44 GMT  
 Unlink Not Working On Windows Server

Quote:
> On Tue, 15 Apr 2003 14:13:48 -0400, "George"

> >use CGI;

> It might be helpful to add this:

> use CGI::Carp qw/fatalsToBrowser/;

> >unlink($delPath$filename);

> And, as Tad said:

> unlink($delPath$filename)  or die "Can't delete $filename: $!;

> Phil
> --
> Ignore coming events if you wish to send me e-mail

Error message as follows:

=====================
Software error:
syntax error at deleteit.cgi line 20, near "unlink"
Execution of deleteit.cgi aborted due to compilation errors.


error message and the time and date of the error.
=====================

Does this mean the errors will be in the error logs or that I will need to
use the command line interface to et details?

-George Conklin
geoATdivergentwebDOTcom
"Insert witty quote here."



Thu, 06 Oct 2005 07:12:40 GMT  
 Unlink Not Working On Windows Server
[Something about unlink]

Quote:
> As I mentioned in my original post I have tried "....die..."
> including the $! and it did not work.

What did not work? The "die"? The "unlink"? The print? The error message?

"Does not work" is about the most useless description of a problem you can
possible write.

Quote:
> I do not have access to the
> command line so far as I know (Telnet?).

Of course you have access to Perl from the command line. Or are you claiming
that your computer does not have a command line? I would find that hard to
believe.
Or are you claiming that your computer has no Perl installed? Then you are
trying to work with both your hands tied behind your back. Untie your hands
and life will be much easier.

Quote:
> I tried the lines below one
> at a time and only got an HTTP 500 "Internal Server Error" :

Please see "perldoc -q 500"

jue



Thu, 06 Oct 2005 07:15:35 GMT  
 Unlink Not Working On Windows Server

Quote:

> =====================
> Software error:
> syntax error at deleteit.cgi line 20, near "unlink"
> Execution of deleteit.cgi aborted due to compilation errors.

Syntax error? Really?
How is that possible? Didn't you check your program before uploading it the
web server?
If you insist on making your life difficult that's your choice. But then
don't cry for help.

Quote:
> =====================

> Does this mean the errors will be in the error logs or that I will
> need to use the command line interface to et details?

Yes.

jue



Thu, 06 Oct 2005 07:20:15 GMT  
 Unlink Not Working On Windows Server

Quote:

>unlink($delPath$filename);

This problem has nothing to do with running on Windows.

--
        Bart.



Thu, 06 Oct 2005 09:31:32 GMT  
 Unlink Not Working On Windows Server

Quote:

>> unlink($delPath$filename);

>If you want to know why the unlink() failed, then you should
>ask why the unlink failed by testing its return value and
>outputting the $! variable's contents:

>   unlink($delPath$filename) or die "could not unlink:  $!";

Come on Tad, you can't be *that* stupid?

It just doesn't compile, that's the problem.

--
        Bart.



Thu, 06 Oct 2005 09:32:41 GMT  
 Unlink Not Working On Windows Server

[snip full-quote]

Quote:
> As I mentioned in my original post I have tried "....die..."  including the
> $! and it did not work.

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

Quote:
> I do not have access to the command line so far as I
> know (Telnet?).

   perldoc -q CGI

       "How can I get better error messages from a CGI program?"

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

Quote:
> I tried the lines below one at a time and only got an HTTP
> 500 "Internal Server Error" :

   perldoc -q CGI  (again)

      "My CGI script runs from the command line but not the
       browser.  (500 Server Error)"

Quote:
> The path to the sample file I am trrying to unlink is
> "/home/httpd/vhosts/thewebsite.com/httpdocs/datafiles/houseimages/".
> Permissions are noted
> below:
> /houseimages - 755

That looks like a Unix path and Unix permissions, but that can't
be, given the Subject you've chosen.

Can paths really look like that on a Windows server?

Have you seen the Posting Guidelines that are posted here frequently?

   http://mail.augustmail.com/~tadmc/clpmisc.shtml

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Thu, 06 Oct 2005 17:35:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Send mail script not working in 2nd server but working in 1st server

2. Send mail script not working in 2nd server but working in 1st server

3. Socket client/server example not working on Windows 2K

4. backticks not working fine on Perl 5 - Windows NT 4.0 peer web server

5. unlink ( deleting file) not working

6. unlink() not working in NT!!??

7. unlink ( deleting file) not working

8. using a mail program to work on Windows NT servers

9. Need, not Needed: Perl/CGI Programmer with knowledge of Windows NT 4.0/Index Server

10. Printing problems (works on Windows, not Linux...)

11. perl cgi not working in windows 2000

12. Script works on Linux but not Windows?????

 

 
Powered by phpBB® Forum Software