Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes I have a need to scan the files over the Internet given their urls. I didn't find any information about this capacity at the documentation of ClamAV. Does it allow to do that? How do I get the result of scanning?

share|improve this question
What do you mean when you say you need to scan the files? – i08in Dec 22 '13 at 7:19
@Jobin, what could I mean by that when I'm taking the antivirus? – アレックス Dec 22 '13 at 7:22
Oh my bad, didn't know ClamAV was an anti-virus software. – i08in Dec 22 '13 at 7:23
up vote 2 down vote accepted

To scan a file you have to download it. You can only scan it on the server if it is your server and you have remote access to it. So if you want to download it from the terminal and run a scan as soon as it is downloaded, you should use a command like:

wget -O /tmp/filetoscan http://LINK_TO_THE_FILE && clamscan /tmp/filetoscan

or if you don't need the file after download, you can pipe it to clamscan:

 wget -qO- http://LINK_TO_THE_FILE | clamscan -

The above will still download the file, the only difference is that it won't store it on your storage. (So your bandwith will be still used during the process, and if you decide that the file is clean, you have to redownload it if you need it on your pc.)

If you don't want to download it, then you have to use a cloud service which downloads and scans it for you, e.g virustotal does it and it scans the file with ClamAV also. Virustotal also has a public API which you can use to initiate scans from your terminal or from any program you write.

If it is your server with clamAV installed on it and you have ssh access to it, then you just ssh to the server and scan the file just like you would scan it on your client. You can use somwthing like:

ssh YOUR_USER@`echo "" | awk -F "/" '{print $1}'` "clamscan /var/www`echo "" | awk -F ".com" '{print $2}'`"

Of course this depends on your server root (/var/www) and whether there are other settings on the server which should be taken into an account when reconstructing the filepath from the URL, but because you know how your server is set up you can do it.

share|improve this answer
If it is your server with clamAV installed on it and you have ssh access to it, then you just ssh to the server and scan the file just like you would scan it on your client. - yes, but how is that related to being able to scan a file given its url? – アレックス Dec 22 '13 at 9:36
@Alex Is it your server? If not, the first part of my answer is relevant to you. If it is yours, then why would you like to scan it based on an URL? But even in the latter case, you can break up that URL (e.g with sed or awk) to the domain name and to the path to the resource and reconstruct the file path from the latter. (Because you know your server setup, it is doable.) Then you use the domain name in the ssh for the server name, and the filepath for the filename, and this means you used the URL for scanning. Good, isn't it? – falconer Dec 22 '13 at 10:00
Yes, it is mine. Why I need it is not relevant. Sorry, I didn't get it. Let's say there is a huge file at which is too much effort to download. How do I scan it for viruses? – アレックス Dec 22 '13 at 10:06
@Alex Update... – falconer Dec 22 '13 at 10:59
@Alex I added also the pipe option,maybe that is what you are interested in, because maybe you are low on storage? I dunno. – falconer Dec 22 '13 at 11:49

You can use curl to do this:

curl | clamscan -

By default, curl will not save the file to your drive space.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.