soheil has asked for the wisdom of the Perl Monks concerning the following question:

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;

Replies are listed 'Best First'.
Re: running tar from a browser
by sschneid (Deacon) on Jul 18, 2002 at 18:41 UTC
    Your script is most likely being executed as the user 'nobody' (the same user the web process is running as), and therefore doesn't have proper access.

    scott.
Re: running tar from a browser
by DamnDirtyApe (Curate) on Jul 18, 2002 at 20:05 UTC

    I've written a handy remote-backup script before (though I don't have it here to post), and I found these modules particularily handy:

    In addition, you could probably make good use of CGI.


    _______________
    D a m n D i r t y A p e
    Home Node | Email
•Re: running tar from a browser
by merlyn (Sage) on Jul 18, 2002 at 21:25 UTC