Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

May 27, 2009

Remove "Computer", "Home", "Trash" icons from Debian 5 desktop, gnome

In terminal, type "gconf-editor". This bring out the GNOME configuration editor.

Go to "apps->nautilus->desktop", uncheck the "computer_icon_visible", "home_icon_visible", "trash_icon_visible" checkboxes.

That's it.

May 8, 2009

Western Digital Essential Edition 1 TB External Hard Drive in Debian 5.0

I installed Debian 5.0 last night. When I tried to copy my music and pictures from my Western Digital Essential Edition 1 TB External Hard Drive to the newly installed machine, it failed me.

The "My Book" name did show at the left tree panel of the file browser. But when I clicked on it, a dialog window prompted up showing that the mounting failed because of invalid parameter.

The external drive's lights were on. But as they were not blinking, I knew that Debian was not reading the external disk. Whatever, I was not sure about the reason of the failure. At first I thought maybe debian didn't support external usb disk as large as 1 TB. Then I searched on line, but got little userful information. Thinking the guide came with the disk may help a little, I took out the disk's package box. To my surprise, I found "Compatibility: Windows Vista/XP/2000; Mac OS X 10.3+" on the box. Debian was not supported, and I never noticed this before!

However, there is always hope. When I just was hesitating whether to switch back to Windows or not, I found this post "Mounting an NTFS drive in Debian". Following the instruction I installed two packages libfuse2 and ntfs-3g with the following commands executed in the terminal.

apt-get install libfuse2
apt-get install ntfs-3g

Guess what, it worked. Now "My Book" was mounted successfully. After all, the problem lied on the two packages.

Mar 20, 2009

Blogging with Windows Live Writer (WLW) from Ubuntu

Not long ago as for my CPE416 Distributed Systems assignment I installed a second OS Ubuntu plus the pre-installed Windows to my Thinkpad T43. Ubuntu is great and I thought I would erase the whole hardhard and then switch from Windows to Ubuntu completely. Before I actually carried out this I found some Windows thing that I would miss from Ubuntu. That is Windows Live Writer. I really like this piece of software - it helps me a lot when I update my blog. Ahhh, then what to do?

Now the problem is solved (nothing is difficult if you take serious of it! :)). I came across this post "How to install Windows Live Writer in Ubuntu(Linux)" when google-ing for the solution. It is easy to deal with the problem. As the blog owner Harihara Kumar put it, what I need to do is just follow the precedure "VirtualBox -> Windows -> WLW". And now it's time to starting blogging locally with WLW!

Following is a screen shot of WLW in Windows in VirutalBox in Ubuntu. hahah!

===============

Don't know what is VirutalBox? "VirtualBox is a general-purpose full virtualizer for x86 hardware. Targeted at server, desktop and embedded use, it is now the only professional-quality virtualization solution that is also Open Source Software. " Want more? No problem. Take a look at its official site: Here.

Mar 19, 2009

linux下c语言socket programming的timeout

cpe416 distributed systems课上的作业要求写一个简单的socket(UDP) program - facility booking system,用client-server的模式写。其中有一个timeout的要求,意思是:client给server发送一个请求,过了一段时间(譬如5秒)之后(timeout了)如果没有收到server的回复,client要再次给server发送请求。

我们group是在linux下用C写这个的,到了timeout这个地方的时候,在网上找到了一个例子。但是原本的code显示timeout功能不怎么明了,我把它改了一点,如下:

#include <STDIO.H> 
#include <SYS/time.h>
#include <SIGNAL.H>
#include <STDLIB.H>

void catch_alarm(int);
void aaa();

int main(){
// install signal hander catch_alarm
// to handle the signal SIGALRM
signal(SIGALRM, catch_alarm);
// to start the timer
alarm(5);

aaa();

return EXIT_SUCCESS;
}

// this is the handler called by kernal
// when timer counts to 0
void catch_alarm(int sig){
printf("Alarm Occurred.\n");
}

// pause at the scanf() line to demonstrate
// the timeout function
void aaa(){
int x;
printf("Please enter an integer: ");
// pause at this line
// after catch_alarm() handles the SIGALRM
// signal, this method continues from here
scanf("%d", &x);
printf("You entered %d.\n", x);
}

上面的signal和alarm两个function是这个timeout的重点了。signal这个function的作用呢,正如comments上面些的那样,它会install一个signal handler给SIGALRM这个signal。然后呢,等这个signal到了的时候“signal handler function for a signal is called ’catching the signal‘.”那么,什么时候这个signal来到?这要看alarm()中写了什么。alarm的定义为:

unsigned int alarm(unsigned int seconds); 

alarm()的作用就是会让系统在seconds秒之后generate一个SIGALRM的信号来,这个时候signal handler也就是catch_alarm()这个么method就会被调用来处理这个signal了。

signal被处理以后这个程序是怎么往下走的呢,这就是上面的例子所要演示的了。当程序print出来“Please enter an integer:“的时候现不要输东西,等到五秒过后,屏幕上会出来“Alarm Occurred.”字样,这说明signal已经来了,而catch_alarm被调用了。这时候再随便打一个数字,按enter,屏幕上又会有“You entered .”字样。这说明signal来的时候,主程序暂停,handler被调用。而handle过了以后,主程序从哪里停的,它便会从哪里继续下去。