I'm setting up a script so that I can input a URL to a web page and the script will wget
the file. Most of the files, however, will be in the *.rar
format. Is there anyway I can pass the filename to the unrar
command to unarchive the files downloaded via wget
?
Many, many thanks in advance!
EDIT I thought about using PHP's explode()
function to break up the URL by the slashes (/
) but that seems a bit hack-y.
@Wyzard gives the best answer. If there's a library that solves your problem, use it instead of forking an external process. It's safer and it's the clean solution. PHP's cURL and RAR are good, use them.
However, if you must use wget
and unrar
, then @rik gives a good answer. wget
's -O filename
option saves the file as filename
, so you don't have to work it out. I would rather pipe wget
's output directly to unrar
though, using wget -q -O - http://www.example.com | unrar
.
@Byron's answer is helpful, but you really should not need to use it here. It is, however, better than using explode()
as your edit mentions.