The Secret Journey

Entries categorized as ‘Programming’

GMail IMAP

January 1, 2008 · Leave a Comment

I have been looking for a way to scan my folder on GMail, parse it, and process information on the folder. I’ve wrote several lines of code in perl, but still have some issues on retrieving several mails.

I have dig the  /usr/local/share/perl/5.8.8/Mail/IMAPClient.pm :

  • found that message_string called fetch
  • tried to download using fetch, also timed out
  • follow up: need to see why fetch timed out

Found a website of IMAP protocol. It may be useful later. Here is the site:

  • http://networking.ringofsaturn.com/Protocols/imap.php

Time to go, will continue tomorrow.

 

Categories: Programming

IMAP::SSL on perl

December 22, 2007 · Leave a Comment

I have an idea to create a script to automate some job on my GMail IMAP folder. However, I was stuck for several days on installing SSLeay modul on my ubuntu. I tried to install either using cpan or compiling it from source. Unfortunately none of them successful.

Finally I found an easy way by just using apt-get to install it. Now I have the module installed, and I can start to write my script

Categories: Programming

Eclipse

June 12, 2007 · Leave a Comment

Finally, I managed to download Eclipse after spending several hours on it.  I don’t have enough time to try it yet. It is almost midnight here in the middle of nowhere.  Looks like that I will have some fun.

Categories: Programming

C Puzzle

May 21, 2007 · Leave a Comment

Categories: Programming

enum

May 8, 2007 · Leave a Comment

In C and C++, enum types can be used to set up collections of named integer constants. (The keyword enum is short for “enumerated”.) The traditional C way of doing this was something like this:

#define SPRING   0
#define SUMMER   1
#define FALL     2
#define WINTER   3

An alternate approach using enum would be

enum { SPRING, SUMMER, FALL, WINTER };

Source: click here

Categories: Programming

what a “struct ospf_packet” for

May 3, 2007 · Leave a Comment

struct ospf_packet
{
struct ospf_packet *next;

/* Pointer to data stream. */
struct stream *s;

/* IP destination address. */
struct in_addr dst;

/* OSPF packet length. */
u_int16_t length;
};

I was not so sure why I would need something like the struct above ? Now I understand that it’s useful to modify anything inside the s. And I would need it for the checksum

Categories: Programming · Quagga

Integer Constant with U ?

May 2, 2007 · 2 Comments

#define OSPF_HEADER_SIZE 24U

Why not defining that with:

#define OSPF_HEADER_SIZE 24

What would make it difference ? Hmmm…

Update:

It will give a different result when we compare it with any number < 0,  the comparison number will be converted to unsigned Integer. Thank you very much to drj11 for the answer.

—————– test.c ———————————–

#define TESTU 24U
#define TEST 24

void main()
{
if (-1<TESTU) printf(“-1< TESTU ! /n”);
if (-1<TEST) printf(“-1< TEST ! /n”);
}

————- EOF ————————————-

Categories: Programming · Quagga

tcl/expect to automate cisco configuration

December 29, 2006 · 3 Comments

It’s the time of learning tcl/expect today. My first script is to read a template configuration from a file and change all of my cisco switch configurations according to the template in one click by using the tcl script.

I like it better than perl since the tcl can work well on my win box without having to run under cygwin. Cool, isn’t it ?

Categories: Network · Programming

First Automation with expect.pm

December 28, 2006 · 1 Comment

Finally I completed my first automation script to change several cisco switch/routers using expect.pm. By using this script, I can save a lot of time to change my switch passwords in one line command. The rest of the job is taken by the script.

Now I can be ready of managind a thousands switches and routers with similar configuration. But, who will give me the routers ? :D

Allright, if you are interested to see this script, just follow this link and send me any feedback if you have any. 

Categories: Network · Programming

not Expect, but telnet

December 28, 2006 · Leave a Comment

Today I test to spawn ftp command by expect.pm. Amazingly, ftp is working fine. Now I understand that it is not expect.pm problem, but something with telnet under cygwin.

Is the problem solved ? Of course not, I need to use telnet instead of ftp. Then I tried to use Net::Telnet. Wow, it works. Now I can use expect for automation of my cisco configuration.

Categories: Network · Programming