in reply to at job help ?
First, like the others have said, the security of this is pretty bad, so you might want to consider alternatives.
To answer your question about the at job:
system("echo \"rm $symlink\" | at now + 1 minute");
Or something similar should do it.
-Pileofrogs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: at job help ?
by merlyn (Sage) on Nov 28, 2005 at 22:18 UTC | |
Well, the perl-ish way of doing that is:
-- Randal L. Schwartz, Perl hacker
| [reply] [d/l] [select] |
|
Re^2: at job help ?
by leocharre (Priest) on Nov 29, 2005 at 15:11 UTC | |
Yes i have abandoned symlink idea- I am doing what ikegami suggested. The octet stream thingie.It works marvelous. Here's the chunk of code..
# the SV hash is non-tainted data, that means at this point the data is
# coming from the server, not the client
# $SV{file_selected_path} is the path to the file in the document
# directory, here there are multiple directories etc
# here we make ugly/azz/filename.pdf to filename.pdf
my $filename = $SV{file_selected_path};$filename=~s/^.+\///;
# $DOC has the absolute path on server to the documents directory
my $FILE;
if (!open($FILE, '<',"$DOC/$SV{file_selected_path}")) {
print "Location: $WWW/?sorry\n\n";
exit;
}
# the next code line makes it so if you go to download.cgi,
# the user gets prompted to do what with filename.pdf, cute.
print(qq|Content-Disposition: attachment; filename="$filename"\n
Content-Type: application/octect-stream\n\n|);
binmode(STDOUT);
binmode($FILE);
$/ = \1024; # Read in blocks of 1024 bytes;
print while <$FILE>;
exit;
| [reply] |
by merlyn (Sage) on Nov 29, 2005 at 15:28 UTC | |
that's application/octet-stream. And you should actually send the proper mime type if you can... see File::MMagic for example. -- Randal L. Schwartz, Perl hacker
| [reply] [d/l] |
by leocharre (Priest) on Dec 07, 2005 at 19:43 UTC | |
Ok.. update .. This is much better now, fixed some stupidity with mimetypes, this is actually important so the client will know what to do with the data. i installed File::MMagic on the server and here's the code to my downloader.. i high-lighted what applies here.
Edit: g0n - replaced pre with code tags | [reply] [d/l] |