The script works, but will only save the new file if I manually delete the old one.I can't get perl to delete it's own file from within perl.
It'd be nice if you supplied us with the error you get when you try, and not to forget, the method you try.
When I try to manually delete it, I get:override rw-r--r-- www/admin for 1image.jpg?
Assuming that your http daemon runs under the user account "www", it looks like a simple unlink should do the trick. That user has write permissions, and should be able to delete the file it created too. You (as in: the user you try to remove the file with) seem to have enough permissions on the directory, but not on the file, hence the warning.
and as www/admin I can.
If you can `su` to user "www" and manually delete it, I see no problems why you can't delete the file (or overwrite it, what you probably want to begin with) from within your script.
I've never seen Image::Grab before, but try this little snippet and please return us the error message you might get (please note that this is almost taken verbatim from the POD):
use Image::Grab; $url = "http://wherever/you/snatch/your/image/from.jpg" $pic->url($url); $file = "/Library/WebServer/Documents/gcdata/".$id."image.jpg"; open(IMAGE, ">$image") || die "Can't open $image: $!"; print IMAGE $pic->image; close IMAGE;
And please check for some weird permissions on "/Library/WebServer/Documents/gcdata/". If, for some reason, you want to alter the permissions the file is saved under, you might want to check out umask too.
$cmd3 = "rm ".$imgfile."";
Please note that you included a ">" sign in $imgfile, which is probably nagging you here. Please don't use that in the filename, but in the open statement (as my example points out) and of course, use unlink instead of system("rm ...") ;)
HTH
In reply to Re: Kill file that I created, and recreate
by b10m
in thread Kill file that I created, and recreate
by ecuguru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |