หน้าเว็บ

วันศุกร์ที่ 31 ตุลาคม พ.ศ. 2551

คำสั่งเข้าหน้า Local Users and Groups

เวลาที่ต้องการจัดการเกี่ยวกับ user ใน windows ให้ไปที่ Run แล้วสั่ง
lusrmgr.msc

ระบบที่ได้ทดลอง
OS: MS Windows XP, Server 2003

วันอังคารที่ 28 ตุลาคม พ.ศ. 2551

คำสั่งที่ใช้ในการตรวจสอบ port ที่เปิดอยู่ใน FreeBSD

ถ้าต้องการรู้ว่าโปรแกรมอะไรมีการเปิด port อะไรไว้บ้าง ก็จะมีคำสั่งคือ sockstat
โดยมี option ที่ใช้บ่อยๆ 4 ตัวคือ
-4 ใช้สำหรับแสดง IPv4 sockets.

-6 ใช้สำหรับแสดง IPv6 sockets.

-c ใช้สำหรับแสดง port ที่มีการเชื่อมต่อ (c = connected)

-l ใช้สำหรับแสดง port ที่เปิดไว้ (l = listen)

เช่น
sockstat -4 -l
ใช้สำหรับแสดง port ทั้งหมดที่เปิดไว้ที่ใช้ IPv4

วันอาทิตย์ที่ 26 ตุลาคม พ.ศ. 2551

List installed package

วิธีสำหรับการตรวจสอบว่าเราได้ลง package อะไรไปแล้วบ้าง

สำหรับตระกูล Redhat, CentOS
rpm -qa
rpm -qa | grep 'package-name'
rpm -qa | grep -i '*httpd*'

สำหรับตระกูล Debian, Ubuntu
dpkg --list
dpkg --list | grep 'package-name'
dpkg --list | grep -i '*php*'

สำหรับตระกูล BSD, OpenBSD, FreeBSD
$ pkg_info
$ pkg_info | grep 'package-name'

ที่มา
http://www.cyberciti.biz/faq/howto-display-list-of-all-installed-software/

วันเสาร์ที่ 25 ตุลาคม พ.ศ. 2551

ปัญหาการลง PIL (Python Image Library) บน FreeBSD

ในการที่จะลง Plone นั้นต้องมีการลง PIL (Python Image Library) ก่อน
แต่พอผมลงแล้วเกิดปัญหาคือพอสั่ง python setup.py build_ext -i แล้วเกิด error ดังนี้

building '_imagingtk' extension

creating build/temp.freebsd-5.5-RELEASE-i386-2.4/Tk

cc -fno-strict-aliasing -DNDEBUG -O -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/freetype2 -IlibImaging -I/usr/local/include -I/usr/include -I/usr/local/include/python2.4 -c _imagingtk.c -o build/temp.freebsd-5.5-RELEASE-i386-2.4/_imagingtk.o

_imagingtk.c:20:16: tk.h: No such file or directory

_imagingtk.c:23: error: syntax error before '*' token

_imagingtk.c:31: error: syntax error before "Tcl_Interp"

_imagingtk.c: In function `_tkinit':

_imagingtk.c:37: error: `Tcl_Interp' undeclared (first use in this function)

_imagingtk.c:37: error: (Each undeclared identifier is reported only once

_imagingtk.c:37: error: for each function it appears in.)

_imagingtk.c:37: error: `interp' undeclared (first use in this function)

_imagingtk.c:45: error: syntax error before ')' token

_imagingtk.c:50: error: `app' undeclared (first use in this function)

_imagingtk.c: At top level:

_imagingtk.c:55: warning: parameter names (without types) in function declaration

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: error: conflicting types for 'TkImaging_Init'

_imagingtk.c:23: error: previous declaration of 'TkImaging_Init' was here

_imagingtk.c:55: warning: data definition has no type or storage class

_imagingtk.c:57: error: syntax error before '&' token

error: command 'cc' failed with exit status 1

ซึ่งปัญหาเค้าว่าอาจเป็นที่ python ได้ถูก link กับ Tkinter และ Tcl/Tk builid libraries แต่ไม่ได้ link กับ Tcl/Tk include files

วิธีแก้
1. locate Tcl/Tk developer package (ผมไม่ได้ทดลองวิธีนี้)
หรือ
2. ให้แก้ไฟล์ setup.py โดยการ comment บรรทัดดังต่อไปนี้ทิ้ง
         elif feature.tcl and feature.tk:
exts.append(Extension(
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
libraries=[feature.tcl, feature.tk]
))
ระบบที่ทดสอบ
OS: FreeBSD 6.2
PIL: 1.1.6
Python: 2.4.5

ที่มา
http://mail.python.org/pipermail/image-sig/2007-November/004662.html

วันศุกร์ที่ 24 ตุลาคม พ.ศ. 2551

วิธีเปลี่ยน default directory ของ Command Prompt (cmd)

บางครั้งถ้าเราต้องมีการเข้า command prompt (cmd) บ่อยๆ แล้วต้องไปที่ directory ใดสักที่หนึ่ง การที่ต้องมาเปลี่ยน directory ทุกครั้งที่เข้า cmd ก็จะค่อนข้างเสียเวลามาก

แต่เราสามารถเปลี่ยน default directory ให้มันได้ดังนี้
1. Start -> Run -> พิมพ์ regedit
2. ไปที่ HKEY_CURRENT_USER \ Software \ Microsoft \ Command Processor
3. ในกรอบทางขวา ในกรณีที่ไม่มี Name ที่ชื่อ Autorun อยู่ให้สร้างขึ้นมาโดย คลิ๊กขวา -> New -> String Value
4. ดับเบิ้ลคลิ๊ก Autorun
5. ในช่อง Value data ให้ใส่ "CD /d " แล้วตามด้วยชื่อ directory ที่เราต้องการ เช่น CD /d C:\Program Files\ เป็นต้น

หรือว่าถ้าเราต้องการสั่งให้มันทำงานอะไรเมื่อเริ่มต้นก็สามารถสร้างไฟล์ .bat แล้วใส่ path ไปยังไฟล์นั้นใน Value data แทนเลยก็ได้

วันเสาร์ที่ 18 ตุลาคม พ.ศ. 2551

การกำหนดค่าที่เซนเซอร์แต่ละตัวอ่านได้ใน TinyDB บน TOSSIM

โดยปกติแล้วถ้า run TinyDB ด้วย TOSSIM นั้น ค่าที่เซนเซอร์แต่ละตัวอ่านได้ในแต่ละช่วงเวลานั้นจะเป็นค่าที่ random ขึ้นมา ซึ่งในบางสถานการณ์เราอาจต้องการ fix ค่า หรือต้องการให้ค่าที่อ่านได้เป็นไปตามสมการที่เรากำหนด (เช่น ในธีสิสผมเป็นต้นที่ต้องการ evaluate ว่าข้อมูลที่อ่านได้ กับข้อมูลที่มีอยู่ในระบบจริงนั้น ถูกต้องขนาดไหน เป็นต้น)

ซึ่ง TinyDB ถ้า compile แบบ make pc เพื่อให้ใช้ TOSSIM แล้วจะเห็นว่าใน Makefile นั้นมีการใช้ Micasb เป็น sensorboard ดังนั้นวิธีที่ผมแก้ง่ายที่สุดคือ ไปสร้าง component ที่ provides interface StdControl และ ADC โดยใน module นั้นก็ให้ทำการสร้าง command async command result_t ADC.getData() แล้วใน command นั้น ก็อาจจะให้ทำการตรวจสอบ TOS_LOCAL_ADDRESS แล้วก็สั่ง signal ADC.dataReady(VALUEที่ต้องการ); เป็นอันเสร็จ

สมมติว่าเราต้องการกำหนดค่าของเซนเซอร์อุณหภูมิ ก็ให้ไปที่ Temp.nc แล้วแก้ไข components PhotoTemp ให้มาใช้ component ของเราแทน และเปลี่ยนการ assign interface StdControl กับ TempADC มาใช้เป็นของเราแทนเช่นเดียวกัน

แล้วก็ทำการ compile ใหม่ เป็นอันเสร็จพิธีครับ

TinyDB บน TOSSIM ไม่แสดงผล

ปัญหาคือลอง run TinyDB โดยใช้ TOSSIM แล้ว ปรากฎว่า พอส่งคิวรีเข้าไปในระบบแล้ว ไม่ได้คำตอบกลับมา คือในหน้าที่เป็นกราฟไม่มีอะไรเกิดขึ้น

จริงๆแล้วไม่รู้ว่าปัญหาคืออะไรเหมือนกัน แต่แก้โดยการคอมไพล์ใหม่ซะเลย

ขั้นแรก
ไปที่ folder tinyos-1.x/apps/TinyDBApp แล้วสั่ง
make clean
ขั้นสอง
ไปที่ tinyos-1.x/tools/java
make clean
ขั้นสาม
ไปที่ tinyos-1.x/tools/java/net/tinyos/tinydb
make -f MakePC
ขั้นสี่
ไปที่ tinyos-1.x/apps/TinyDBApp อีกครั้ง
make -f MakePC pc
เป็นอันเสร็จ พอจะทำงานก็เปิดสอง shell
shell แรกไปที่ /tinyos-1.x/apps/TinyDBApp
./build/pc/main.exe
shell ที่สองไปที่ /tinyos-1.x/tools/java
java net.tinyos.tinydb.TinyDBMain -sim
Environment ที่ทดสอบ
TinyOS: 1.1.15 snapshot
TinyDB: 1.1.3
OS: Cygwin on WIndows XP