Thursday, April 1, 2010

Change the desktop background using Perl script - GNOME (Fedora and Ubuntu)

Hi Guys,

These days people are opting Linux distributions like Fedora, Ubuntu, etc., for their PC's mainly to avoid malware and virus attacks. Bundling them with all kind of multimedia and entertainment tools make them more interesting and the fact that they are free make them further irresistible.

Many of the home users find them wanting. But there are small things that you would find irritating, say, something as simple as changing the desktop background. To make your life simple, here I have made a simple, sample perl script to change the desktop image. It will download pictures from National Geographic website and set it as your wallpaper. This is just a sample script, if you have the time please try it out with different website/urls. I am sure, you might as well start learning perl like I did... :-)

Note : If you want to run this script daily, just add an entry in the crontab. Crontab entry must be Xserver login user and not other users.

Here the script:-
-----------------

#!/usr/bin/perl

use WWW::Mechanize;

my $url  = "http://photography.nationalgeographic.com/photography/photo-of-the-day/";

my $mech  = WWW::Mechanize->new();
$mech->get( $url );
my @links = $mech->links();
my $download_link;

foreach my $link (@links)
{
   if  ($link->text() eq "Download Wallpaper (1600 x 1200 pixels)")
      {
       $download_link = $link->url();
       last;
      }
}

$uri = $download_link;
$date_time = localtime(time);
my @file_name = split(' ',$date_time);

#Picture will be stored in "/home/vivek/Pictures/" folder and file will be like this "Apr-1-2010.jpg"
#Change the path/folder...
 
$tempfile = "/home/vivek/Pictures/$file_name[1]-$file_name[2]-$file_name[4].jpg";

$mech->get( $uri, ':content_file' => $tempfile );


if ( -e $tempfile )
{
system("gconftool-2 --type string --set /desktop/gnome/background/picture_filename $tempfile");
}

-------------------

Important links:-

http://photography.nationalgeographic.com/photography/photo-of-the-day/
http://search.cpan.org/~petdance/WWW-Mechanize-1.60/lib/WWW/Mechanize.pm

Thursday, March 18, 2010

Pidgin-2.6.6 for Fedora 8

Hi friends,

I hope most of you are using Pidgin IM for chat. Till (Mar/19/2010) Pidgin latest version 2.6.6 is not available for Fedora 8 release. I have created the pidgin and libpurple rpm packages for Fedora 8 (i386) based on their source rpm.

Link for download:

Create a local repository and update the pidgin using YUM or install directly via RPM.

Regards,
Vivek

Friday, December 5, 2008

IP-to-IP tunneling

This works under Linux machine
SERVER A:

OS: Linux
Network Interface: eth0
IP: 172.16.0.1

SERVER B:

OS: Linux
Network Interface: eth0
IP: 172.16.0.2

Now we create the tunnel with following parameters.
SERVER A: 10.0.0.1 / 255.255.255.252
SERVER B: 10.0.0.2 / 255.255.255.252

In Server A:

ip tunnel add tun0 mode ipip remote 172.16.0.1 local 172.16.0.2 dev eth0
ifconfig tun0 10.0.0.1 netmask 255.255.255.252 pointopoint 10.0.0.2
ifconfig tun0 mtu 1500 up

In Server B:
ip tunnel add tun0 mode ipip remote 172.16.0.2 local 172.16.0.1 dev eth0
ifconfig tun0 10.0.0.2 netmask 255.255.255.252 pointopoint 10.0.0.1
ifconfig tun0 mtu 1500 up

Now ping 10.0.0.2 from server A:
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.139 ms
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.139 ms

Finish..

All the best.

Thursday, November 27, 2008

Squid Installation in Linux

1. Download the source from squid-cache.org.

2. Untar the source file.

3. Go to squid source directory.

4.In terminal execute the command " ./configure ".

5. After completing the configuration just execute " make & make install ".

6. Now squid will be installed in " /usr/local/squid ".

7. Go to squid directory and open configuration file using vi editor like " vi etc/squid.conf " and
put these line " visible_hostname localhost ".

8. Execute the command " ./sbin/squid -z".

9. Now swap directories has created.

10. Then start the squid " ./sbin/squid -D ".

*. Normally squid runs on 3128 port.

More visit: http://squid.visolve.com/

Wednesday, October 8, 2008

Linux - Open Source - Daily Tips

Install New fonts in Linux ( Fedora and RedHat )

1. Download the font

2. Copy that font in to /usr/share/fonts

3. Then restart the Xserver [Log off and Log in again].

4. Now new font comes to usage for all applications
like Mozilla,Thunderbird etc....

Note : Tested Under Redhat and Fedora.


Iptable Tips

Open FTP (port 21) for local network

 iptables -I INPUT -s 192.168.1.0/255.255.255.0 -p tcp --dport 21 -j ACCEPT
OR Block FTP port for local network

 iptables -I INPUT -s 192.168.1.0/255.255.255.0 -p tcp --dport 21 -j REJECT
Change the file descriptor value

It will increase the performance of the whole server or system.

View the existing value using -> cat /proc/sys/fs/file-max

Change the Maximum file descriptor value by using this command -> echo 65536 > /proc/sys/fs/file-max

The above example, we should change file descriptor value to 65536.

Today's Quote:
The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it
--Linus Torvalds--

Regards,
Vivekanandan N.