Tuesday, August 17, 2010

Linux Bash Script: "not a valid identifier" problem

The "not a valid identifier" problem showed up when I tried to read user input with bash scripting on my Ubuntu box. This part of my script is simply something like:

# !/bin/bash
echo -e "Please input a word: \c "
read word
echo "The word you entered is: $word"

This was streight forward and should not have any problem. However, it responsed:

$ ./read.sh
Please input a word: river
': not a valid identifier`word
The word you entered is:

The explanation for such an embarrassing situation is also simple. Since I wrote the script with notepad++ under windows, the script was set to DOS formatting instead of UNIX formatting. i.e. the line breaker was \n instead of \r.

There is one solution to covert all \n to \r\n to solve this problem:

$ perl -i -pne "s/\n/\r\n/g" filename

The lesson I learn again is: Unix and Windows... they really do not like each other.

More ...

Wednesday, August 11, 2010

Project - Samba: Checklist

11 things to check before putting Samba server to work:

1 - smb.conf

$ testparm /etc/smb.conf

2 - connection: ping

$ ping mfhk-riverliu

If return ‘host not found’ or a similar message, then your DNS software or /etc/hosts file is not correctly set up.

Elseif other ping errors, go to check 3 - the firewall.

C:\> ping test-samba

$ hostname
$ hostname -a
$ hostname -f

3 - firewall

$ iptables -L -v
$ ipchains -L -v

4 - List shares from Samba server

$ smbclient -L test-samba

If you get an error message containing the string ‘bad password’, then you probably have either an incorrect hosts allow, hosts deny, or valid users line in your smb.conf, or your guest account is not valid. Check what your guest account is using testparm and temporarily remove any incorrect hosts allow, hosts deny, or valid users lines.

If you get a message connection refused response, then the smbd server may not be running. If you installed it in inetd.conf, then you probably edited that file incorrectly. If you installed it as a daemon, then check that it is running and check that the netbios-ssn port is in a LISTEN state using netstat -a.

Note: Some UNIX/Linux systems use xinetd in place of inetd. Check your system documentation for the location of the control files for your particular system implementation of the network super daemon.

...

5 - Return IP of Samba server

$ nmblookup -B test-samba __SAMBA__

6 - Return IP of Samba client

$ nmblookup -B mfhk-riverliu "*"

7 - Query boardcast

$ nmblookup -d 2 "*"

8 - Enter share

$ smbclient //test-samba/share-name

9 - net view

C:\> net view \\test-samba

10 - net use

C:\> net use \\test-samba\share-name

11 - Return IP of master browser of workgroup

$ nmblookup -M workgroup-name

More ...

Monday, August 9, 2010

Add "read more" in Blogger

Usually Blogger shows the whole post on main page by default. It is quite annoying, especially when I post a long document describing something like Samba configuration.

I searched the internet for solution of showing the start of post on main page. Some were quite good, but still not perfect when dueling with the customized pages. That is the reason for me to write this solution:

Point to Design | Edit HTML. Check Expand Widget Templates.

Inside the HTML box, there should be a line like

<data:post.body/>

replace this line with

<b:if cond='data:blog.pageType != "static_page"'>
    <b:if cond='data:blog.pageType == "item"'>
        <style>.fullpost{display:inline;}</style>
        <data:post.body/>
    <b:else/>
        <style>.fullpost{display:none;}</style>
        <p><data:post.body/>
            <b:if cond='data:post.url'>
                <a expr:href='data:post.url'>More ...</a>
            <b:else/>
                <data:post.title/>
            </b:if>
        </p>
    </b:if>
<b:else/>
    <data:post.body/>
</b:if>

Then save this template.

Point to Setting | Formatting . Add this line to Post Template:

<div class="fullpost"></div>

For each post, the "more" part should be enclosed within the div shown above.

More ...

Biweekly Report - Report 5

26 Jul 2010 – 6 Aug 2010

1. Things I did:

In the first week, I began with re-design the Information Collector I started a few weeks ago. Then I was introduced to a new project to construct a file server for Guangzhou office with Samba, an open source package for file sharing and security control. I studied it for days, to get familiar with its features, functions and usages. Then I built a Samba server on Debian Linux system (Ubuntu 10.04 LTS) for testing and configured basic setting by the end of this week.

In the second week, I continued with the Samba server I built last week. I focused on its security issues, accessibility and networking this time. Also I went through the official guide HOWTO of more than 540 pages and the official example book ByExampleof more than 640 pages to be able to use the Samba under various conditions.

2. Things I learnt

Although I had been working on Linux system for years, it was the first time for me to know about Samba, and lots of relative terminologies, like NetBT, NetBIOS, SMB, CIFS and Opportunistic locking. During the Samba server testing, I also had a better understanding of Linux-Windows interaction and NT domain.

The other skill I improved was time management. It was always a good practise to retrive useful information from large amount of data in limited time.

3. Expectations

I wish to continue to work on Samba server, especially on method to map Windows NT accounts to Unix accounts, so that Windows NT users no longer need to have separate accounts on the Samba server.

Also I wish to install the file server system for Guangchou office in real sitaution in the following two weeks before the end of my internship.

More ...

Friday, August 6, 2010

Intel processors


What's i386? I started to think about this question when I was downloading the Ubuntu of i386 version. I think that i386 is a category of CPU. Well, this is not totally unreaonable.

i386 is short for the Intel 80386, which is produced since 1985 until 2008. So far the 80386 instruction set, programming model, and binary encodings are still the common denominator for all 32-bit x86 processors. However this is termed x86, IA-32, or the i386-architecture, depending on context.

The CPU of my workstation is Intel Celeron (R) , belongs to x86 family.

I catched the list blow from Wikipedia.com, just for fun to know.

More ...

Recover Deleted Folder in MS Outlook

Have you ever deleted a folder but want it back later while using MS Outlook? A colleague asked my help to recover her accidentally deleted "Unread" folder. The recovery strategy is straight forward, but extremely helpful for some other case like filtering and trashing.

I will take the "Unread" folder as an example to show how to recover/create folders in MS Outlook.

1. Right click "Inbox" folder (aka the parent folder that your new folder will belong to)
2. Go to Advanced Find..
3. Go to More Choice tab
4. Select Only items that are: then Unread in the menu to its right side.
5. Point to File | Save Search As Search Folder...
6. Name the new folder and click OK to finish



Congratulations! The unread folder just been recreated! It will be shown on the folder list.

You may also find this method useful for other tasks, like filtering letters with specific words, date or something else. Try it yourself!


More ...

Thursday, August 5, 2010

VWare Player

I am still waiting for VWare Player installer to finish its downloading.

VWare is so funny that it created a so call installer using java, just for downloading and launching the setup file. I suppose that the only thing it may show is how slow could java be.



BTW, I add a picture because Jolin, one of my colleagues, complained that this work blog was too boring and dull. Actually, she also cited a famous saying which is something like "NO PICTURE NO TRUTH". Well, I cannot find more attractive pictures since I always work with cmd, script and terminal. However, GUI is great and will always be great to show.

More ...