Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36

Thread: Add right-click virus scanning capability to Nautilus

  1. #1
    Join Date
    Jul 2005
    Beans
    Hidden!
    Distro
    Ubuntu
    With this script saved in ~/.gnome2/nautilus-scripts, you can scan files or directories for viruses by simply right-clicking on them in Nautilus and selecting this script from the, "Scripts" dropdown menu. It relies on Clam Anti-virus which can be easily installed by doing, "sudo apt-get install clamav" in a shell. Simply copy the code below, into a text file and save it as, "virus-scan" and make it executable (ex: chmod 755 virus-scan). Again, it needs to be located in your ~/.gnome2/nautilus-scripts (dot in front of 'gnome2') directory. Anyway, here's the script:

    Code:
    #!/bin/bash
    #
    #  Nautilus anti-virus scanner script v1.2 - Uses Clam Anti-virus
    #  Written by Robert Pectol, December 2005 - http://rob.pectol.com
    #
    #  This program is free software.  It is distributed in the hope
    #  that it will be useful, but WITHOUT ANY WARRANTY; without even
    #  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    #  PURPOSE.  See the GNU General Public License for more details.
    ######################################################################
    
    #  Set some variables used in the script
    files=$1
    if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then
            files_path=$HOME"/Desktop"
    else
            files_path=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed -e 's/^file:\/\///'`
    fi
    gui=`which zenity`
    vscan=`which clamscan`
    
    #  Function to scan file(s)
    scan_it()
    {
            touch /tmp/scanresult
            if [ "$files_path" = "" ]; then
                    #  Script can run from launchers, scripts other than from Nautilus, etc. (doesn't require $NAUTILUS_SCRIPT_CURRENT_URI)
                    result=`$vscan -r "$files" --log=/tmp/scanresult | $gui --title "Virus Scanner" --progress \
                    --text="Scanning $files..." --pulsate --auto-close; cat /tmp/scanresult` &> /dev/null
            else
                    result=`$vscan -r "$files_path/$files" --log=/tmp/scanresult | $gui --title "Virus Scanner" --progress \
                    --text="Scanning $files..." --pulsate --auto-close; cat /tmp/scanresult` &> /dev/null
            fi
            rm -f /tmp/scanresult &> /dev/null
            #  Feedback - if scan ended with errors or was terminated prematurely...
            if [ "$result" = "" ]; then
                    err_text="Virus scan on $files terminated!"
                    errors
            fi
            #  Feedback - if scan completed successfully...
            clean=`echo $result | grep 'FOUND'`
            #  Alter gui feedback according to presense/absense of virus(s) found during scan
            if [ "$clean" != "" ]; then
                    $gui  --title "Virus Found!" --error --text="$result" &> /dev/null
            else
                    $gui  --title "Virus Scan Results!" --info --text="$result" & &> /dev/null
            fi
    }
    #  Function to handle errors
    errors()
    {
            $gui  --title "Virus Scan Error!" --error --text="$err_text" &> /dev/null
            exit 1
    }
    
    #  Check for presense of required utilities
    if [[ -x "$vscan" && -x "$gui" ]]; then
            scan_it
    else
            if [ -x "$vscan" ]; then
                    echo "Zenity was NOT found on the system!"
                    exit 1
            else
                    err_text="Clam Anti-virus was NOT found on the system!"
                    errors
            fi
    fi
    exit 0
    Enjoy!
    Last edited by robert_pectol; January 5th, 2006 at 04:12 PM.
    Rob

  2. #2
    Join Date
    Jul 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Add right-click virus scanning capability to Nautilus

    Deleted!
    I edited the original post to include the info contained in this one!
    Last edited by robert_pectol; January 5th, 2006 at 04:14 PM.
    Rob

  3. #3
    Join Date
    Feb 2005
    Location
    Brazil
    Beans
    69

    Re: Add right-click virus scanning capability to Nautilus

    Good, thanks!
    It works even for folders.
    You can't always get what you want

  4. #4
    Join Date
    Jul 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Add right-click virus scanning capability to Nautilus

    You're welcome! I'm also working on a file encrypter/decrypter script for Nautilus. It uses GnuPG. If there's any interest in such a script, let me know and I'll dedicate some more time to it to get it done sooner.
    Rob

  5. #5
    Join Date
    Apr 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Add right-click virus scanning capability to Nautilus

    It gives and error...

    'Error: Can't access' what ever file/folder I'm trying to scan

    edit: It only does that when scanning files on the desktop.
    Last edited by Rob2687; December 17th, 2005 at 10:30 PM.

  6. #6
    Join Date
    Sep 2005
    Location
    Barcelona
    Beans
    36
    Distro
    Ubuntu Breezy 5.10

    Re: Add right-click virus scanning capability to Nautilus

    Quote Originally Posted by Rob2687
    It gives and error...

    'Error: Can't access' what ever file/folder I'm trying to scan

    edit: It only does that when scanning files on the desktop.
    Yep, appart from that issue it works like a charm.

    Thanks for the howto.
    MSI K8N Neo2 Platinum | A64 Winchester 3000+@2,5GHz 1.4V | XP-90+PAPST 92x92 | GeForce 6800GT@Ultra (416/1120)
    2x512MB Elixir PC3200@PC3700 | 80GB Seagate P-ATA100 | Samsung SD-616Q | Sony DRU710A | Tagan 480W | Lian Li PC-60 | Flatron F700P

  7. #7
    Join Date
    Feb 2005
    Location
    Brazil
    Beans
    69

    Re: Add right-click virus scanning capability to Nautilus

    Quote Originally Posted by robert_pectol
    You're welcome! I'm also working on a file encrypter/decrypter script for Nautilus. It uses GnuPG. If there's any interest in such a script, let me know and I'll dedicate some more time to it to get it done sooner.
    C'mon, let's see it....
    You can't always get what you want

  8. #8
    Join Date
    Jul 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Add right-click virus scanning capability to Nautilus

    Thanks for letting me know. It was a minor bug and I've addressed it with this new version. It seems to have been an issue with the script knowing the full path to the directories/files to be scanned, and getting that info from Nautilus. So, I've made a couple of changes to the script to do that. I've tested it here locally and so far, it appears to be fixed. Give it a try and let me know. If you can break it, I'd like to hear about it. That's how these things get ironed out! I've replaced the script on the original posting with the updated version. If the script didn't get pasted properly or you'd like to download it directly, it is available here:
    http://rob.pectol.com/myscripts/vscan.sh.txt
    Last edited by robert_pectol; January 5th, 2006 at 04:26 PM.
    Rob

  9. #9
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,510
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Add right-click virus scanning capability to Nautilus

    Good stuff, thanks for doing it!
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  10. #10
    Join Date
    Dec 2005
    Location
    A Brit in Lezardrieux, Fr
    Beans
    1,595
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Add right-click virus scanning capability to Nautilus

    Rob. Thank you.

    Having looked at the code I realise that I could probably have written it myself - but I didn't and you did! Good effort. (perhaps I might even try some of my own)
    When someone says 'I cannot do this in Linux, the limitation is not in the software, but simply in their knowledge.'
    Linux User - 380191

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •