Wanted to create backups at certain intervals for a very important server. And what’s more I wanted to make sure that the backups were in couple of places. Including my e-mail. So, I bash script was created!
Now you may notice you will need to install couple of packages to your server. These are ;
Mutt : Setting mutt is very easy. Simply search gmail mutt configuration in google. Who knows. May be you will find me in the process.
lftp : You don’t need to set this. And the packages for this is readily available for ubuntu and fedora distros.
Now all you need is to save this little script and call it from cron in periods of your wish.
For those wondering what message2.txt contains. It is a daily usage report that is created by a python script I wrote. However you can simply create a simple txt file of your choosing. That way mutt will include that text in to your e-mail.
I know there a lot of examples of WebCAM image capturing on the net. Mine is one of that but the main difference is that this little script here simply captures frames in a certain fps and simply saves those images. There a numerous usages for such a thing. One usage could be a script that uploads this image to a certain ftp site so you can display it in your web page. I needed this little script to follow a moving object. I did not write the whole script. You may think this as a little upgrade from the one on the internet. The script uses OpenCV and Pygame libs. Without further ado the script :
from pygame.locals import *
#this is important for capturing/displaying images
from opencv import highgui
camera = highgui.cvCreateCameraCapture(0)
im = highgui.cvQueryFrame(camera)
# Add the line below if you need it (Ubuntu 8.04+)
#im = opencv.cvGetMat(im)
#convert Ipl image to PIL image
fps = 25.0
window = pygame.display.set_mode((640,480))
screen = pygame.display.get_surface()
events = pygame.event.get()
for event in events:
if event.type == QUIT or event.type == KEYDOWN:
im = get_image()
#allowing the camera to focus
#auto focus is really annoying
pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
pygame.time.delay(int(1000 * 1.0/fps))
If you are geek your mouth should be watering by now. I will like to thank Oscar Lindberg and his cool Linux friend for this code! I was trying to get multiple-mice movement data. This is the code that got me started. Once I beautify my multiple-mouse code I will be posting it here as well. Without further ado :
mouse = file('/dev/input/mouse0')
status, dx, dy = tuple(ord(c) for c in mouse.read(3))
return n - ((0x80 & n) << 1)
dx = to_signed(dx)
dy = to_signed(dy)
print "%#02x %d %d" % (status, dx, dy)
Following the previous posts in this category you will notice that I was using Sourceforge.net as the code hosting. We had to change that because we really didn’t want to share every bit of code. ( A big sorry to open source developers. I am truly a sell out. ) So had to set up CVS server. Never done that before. Should probably add it to my CV. Anyways to business.
We have been able to install Ångström Linux to our beagle board. Ran into couple problems. The first one was we trusted BeagleBoard Beginners wiki just too much!!
You see we learned that we should NOT set any environment variables while using demo u-boot image which was downloaded from here. In fact what we did is we created our own Ångström image (from Ångström site) and simply installed that to our Linux partition of our SDHC card. And it worked beautifully. Though I must say first boot is a drag, very very slow.
Have just upgraded my dual-boot (WindowsVista/Fedora 11) laptop (HP Compaq Presario CQ50). I simply downloaded an upgrade ISO from https://fedoraproject.org/get-fedora . Than burned it to a DVD. Started my Fedora 11 and updated it by calling in the command “yum update”. Restarted the laptop with the DVD in and voilà I had my computer updated. Had some trouble with the household though because I was updating my desktop (WindowsXP/OpenSUSE) and my borrowed other laptop (Fedora 11) at the same time.
Even tough the team’s enthusiasm was up the roof we were not able to try it out. More on this later. I would also like to inform all people who is following this blog religiously that our project is now hosted on SourceForge.net at http://sourceforge.net/projects/theblackbox/ . And I have also set up a CVS so those who want to follow the code will be able to follow it from the net.
cvs -z3 -d:pserver:firstname.lastname@example.org:/cvsroot/theblackbox co -P modulename
I am sorry to say due to some weird problem you can not view the CVS modules from Sourceforge. You will need to use some kind of client. I am currently using Eclipse as my development IDE hence all my CVS materials comes from that. I have heard that TortoiseCVS is quite neat in its own way (for Windows) but I’d rather use Eclipse your choice.