Quote:
Originally Posted by or1on
Can someone help me out on how to program a bash script to scan a USB upon insert? And in the script I would like to send a notification to user about the progress. Like "Scanning USB for virus". Then "USB Scan Completed?". I would like to be able to open clamtk when the user plugs the USB. Please help?
|
There are two seperate problems you need to solve.
The first one is to run a script upon insertion of the usb stick. This can be achieved via
udev rules.
Showing output to the user can be achieved in many different ways, one of which is the xmessage command. Try experimenting with it on the command line before including it into your script. (Depending on your disto you might have to install it first, on Arch the package name is xorg-xmessage, in Debian-land (so probably also the *buntus) it should be x11-utils
Note that when called from within a script that is triggered via udev you won't see anything by default unless you set the DISPLAY environment variable beforehand.
Example:
Code:
export DISPLAY=:0
xmessage "Virus scan complete"
The value :0 may be different on your machine.
You can find out the correct value for DISPLAY by running
Alternatively to xmessage you can also open a terminal emulator that runs your script.
Code:
export DISPLAY=:0
xterm -e "/path/to/script.sh"
The advantage is that you can inform the user about progress via messages to stdout.