huck has asked for the wisdom of the Perl Monks concerning the following question:
I am reaching my wits end. I manage a small website for a friend. They want it on yahoo because it has been there and they have their mail addresses there. Recently something happened that caused updates and backups to stop working. The customer services group has been of no help so i have dug farther myself. I created the following perl program
When i run that program i get the following result.#!/usr/bin/perl -w use strict; use warnings; use CGI; my $q = CGI->new; print $q->header('text/html'); print "<html><head><title>renamehuh Perl</title></head>\n<body>\n"; print '<h1>Why doesnt this work</h1>'."\n"; print '<pre>'."\n"; my $dir='/saveit/md5test'; use File::Basename; my $file=$dir.'/huh.saveit'; my $dpart=dirname ($file); my $fpart=basename($file); my $nback=5; if ($nback){ if (-e $dpart.'/bkup'.$nback.'-'.$fpart) { unlink $dpart.'/bkup' +.$nback.'-'.$fpart; } for (;$nback>1;$nback--){ my $nback1=$nback-1; my $thisfn=$dpart.'/bkup'.$nback1.'-'.$fpart; if (-e $thisfn) { myrename ($thisfn,$dpart.'/bkup'.$nback.'-'. +$fpart);} } if (-e $file) { myrename ($file,$dpart.'/bkup'.$nback.'-'.$fpart +); } } #nback open (my $out,'>',$file); my $time=time; print $out "hi $time\n"; close $out; use HTML::Entities qw/encode_entities/; print "\n\n<hr> perl program is $0 \n"; open (my $iam,'<',$0); while (my $line=<$iam>){ chomp $line; print encode_entities($line)."\n"; } exit; sub myrename{ my $thisfn=shift; my $newfn=shift; print " \n"; if (-f $thisfn) {print "$thisfn exists \n";} print "rename $thisfn,$newfn\n"; my $ok=rename $thisfn,$newfn; unless ($ok) {print "Cant rename $thisfn $newfn $!\n";} unless (-e $newfn) {print " .. $newfn doesnt exist \n";} return $ok; } #
As you can see the my $ok=rename $thisfn,$newfn; is returning false and presenting "No such file or directory" in $!./saveit/md5test/huh.saveit exists rename /saveit/md5test/huh.saveit,/saveit/md5test/bkup1-huh.saveit Cant rename /saveit/md5test/huh.saveit /saveit/md5test/bkup1-huh.savei +t No such file or directory .. /saveit/md5test/bkup1-huh.saveit doesnt exist
Customer service tried to tell me that it is because of .htaccess files. I find this hard to believe. Anyway for some reason yahoo is hiding dot-files from me via SFTP WINscp (also a FTP manager) and filezilla and their online file manager so i cannot remove them, and unlink/rename isnt working on them either
Does anyone have any ideas (besides yahoo being hosed) that could help me?
The base code is part of a backup procedure of mine that keeps prior copies in files named bkup1-huh.saveit, bkup2-huh.saveit, bkup3-huh.saveit ,bkup4-huh.saveit ,bkup5-huh.saveit. It works on 3 other linux boxes and about 4 windows boxes just fine, but not at yahoo.
If i run unlink $file; on yahoo i get the same false result and error in $!
Edit: the permissions on the file are 664, i tried 777 but it made no difference, when i create the file via the web or FTP the uid/gid look the same as any other file on the website too
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problems with basic perl/unix commands on yahoo small business services
by hippo (Archbishop) on Aug 02, 2017 at 09:15 UTC | |
by huck (Prior) on Aug 02, 2017 at 11:35 UTC | |
by karlgoethebier (Abbot) on Aug 02, 2017 at 16:57 UTC | |
|
Re: problems with basic perl/unix commands on yahoo small business services
by Anonymous Monk on Aug 02, 2017 at 11:17 UTC |