Hello everyone.
Here is my problem:
Running, Linux.
I am trying to write a simple backup program to backup the data from a directory.
The script works from the command line.
But when I try to run the same script from the browser, it doesn't work.
I get this message:
"Data could not be backed up.
Exited with the following message: No such file or directory"
The error logs say:
tar: backup.tar: Permission denied
tar: Error is not recoverable: exiting now
Can anyone please help me?
Here is the contents of the script:
#!/usr/bin/perl
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ct
+ime,$blksize,$block);
my $command1 = "tar cvf backup.tar members templates reviews";
system($command1);
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime
+,$blksize,$block) = stat "backup.tar";
my $DAT_SIZE = $size;
print "Content-Type: text/html\n\n";
if (-e "backup.tar") {
print "<CENTER><H1>Backup complete.</H1></CENTER><BLOCKQUOTE><
+BLOCKQUOTE>\n";
print "<H4>We recommend that you download the <BLOCKQUOTE><A H
+REF=\"backup.tar\">Data Backup File ($DAT_SIZE Bytes)</A></BLOCKQUOTE
+>to your local computer for safe keeping...</H4>\n";
print "</CENTER><BLOCKQUOTE>Note: The backup file (backup.tar)
+ is in the same directory as your CGI Programs Data. It is possible
+that you may not be able to download it using the link above (.cgi-bi
+n directories will not allow downloads from them). If you cannot dow
+nload it with the provided link, we recommend that you FTP into your
+server and retreive the file manually.</BLOCKQUOTE></BLOCKQUOTE>\n";
}
else {
print "<CENTER><H1>Data could not be backed up.</H1>\n";
print "<H4>Exited with the following message: $!</H4>\n";
}
exit 0;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.