Tuesday, December 16, 2008

Avoid auto padding by PIC32 compiler for data structure

Using __attribute__((packed)) for variable and structure member.




typedef struct sDaq2ComAggregationRaw001
{
GSNTYPES_BYTE FeederAndPhase; //0x01:Va 0x02:Vb....
GSNTYPES_BYTE TimeStampCycles;
GSNTYPES_ULONG TimeStampSeconds;
GSNTYPES_DOUBLE llDft_Goertzel_Aggregation_SquareSumImgReal[CABLE_TRACKER_MAX_NUM_HARMONICS]; GSNTYPES_DOUBLE llSquareSumForAggregationLog;
GSNTYPES_DOUBLE llSquareSumPerCycleMaxOverLoggingInterval; //Optional to be logged.--advanced feature ToDo
GSNTYPES_DOUBLE llSquareSumPerCycleMinOverLoggingInterval; //Optional to be logged.--advanced feature ToDo

}
__attribute__((packed)) S_DAQ2COM_AGGREGATION_RAW_001;



typedef struct sDaq2ComAggregationRaw002
{
GSNTYPES_BYTE FeederAndPhase; //0x11:Feeder1PhaseA, 0x12:Feeder1PhaseB...0x41:Feeder4PhaseA
GSNTYPES_BYTE TimeStampCycles;
GSNTYPES_ULONG TimeStampSeconds;
GSNTYPES_DOUBLE llDft_Goertzel_Aggregation_SquareSumImgReal[CABLE_TRACKER_MAX_NUM_HARMONICS]; GSNTYPES_DOUBLE llSquareSumForAggregationLog;
GSNTYPES_DOUBLE llSquareSumPerCycleMaxOverLoggingInterval;
GSNTYPES_DOUBLE llSquareSumPerCycleMinOverLoggingInterval;
GSNTYPES_DOUBLE llActivePwrSumForAggregationLog; //

}
__attribute__((packed)) S_DAQ2COM_AGGREGATION_RAW_002;



typedef struct sStructureID
{
GSNTYPES_USHORT variation;
GSNTYPES_BYTE version;
GSNTYPES_BYTE type; //config, log, events. see E_StructType definition.

}__attribute__((packed)) S_StructureID;


typedef struct sRdHeadDataStorage
{
GSNTYPES_USHORT len; //is based on the struct ID,number bytes of record body,exclude record header.
S_StructureID structID;
}S_RecordHeadDataStorage;



typedef union sDataRecordBody
{
//The ptrDataBody could point to following data Structures.

S_COM_CONFIG_BLOCK_001 com_configuration_001;
S_COM_CONFIG_BLOCK_002 com_configuration_002;
S_DAQ_CONFIG_BLOCK_001 daq_configuration_001;
S_DAQ_CONFIG_BLOCK_002 daq_configuration_002;
S_DAQ2COM_AGGREGATION_RAW_001 daq2com_aggregation_raw_001;
S_DAQ2COM_AGGREGATION_RAW_002 daq2com_aggregation_raw_002;
S_DAQ2COM_AGGREGATION_RAW_003 daq2com_aggregation_raw_003;
S_DAQ2COM_EVENTS_RAW_001 daq2com_events_raw_001;
S_DAQ2COM_EVENTS_RAW_002 daq2com_events_raw_002;
S_DAQ2COM_EVENTS_RAW_003 daq2com_events_raw_003;
S_COM2EEP_AGGREGATION_REAL_001 com2eep_aggregation_real_001;
S_COM2EEP_AGGREGATION_REAL_002 com2eep_aggregation_real_002;
S_COM2EEP_AGGREGATION_REAL_003 com2eep_aggregation_real_003;
S_COM2EEP_EVENTS_REAL_001 com2eep_events_real_001;
S_COM2EEP_EVENTS_REAL_002 com2eep_events_real_002;
S_COM2EEP_EVENTS_REAL_003 com2eep_events_real_003;

}U_DataRecordBody;


typedef struct sDataRecord
{
S_RecordHeadDataStorage rdHead;
U_DataRecordBody rdDataBody;

}__attribute__((packed)) S_DataRecord;

Monday, December 1, 2008

Basic linux command list under Fedora

SHOW PERL VERSION
SHOW LINUX KERNEL VERSION
SHOW WHETHER LINUX KERNEL SOURCE CODE ARE INSTALLED
cscope
SHOW PERL VERSION
[q.yang@localhost lpc3250]$ perl -v
SHOW LINUX KERNEL VERSION

[q.yang@localhost lpc3250]$ uname -r

SHOW WHETHER LINUX KERNEL SOURCE CODE ARE INSTALLED

[q.yang@localhost sierra_drv_1.7.32]$ rpm -qa|grep kernel
kerneloops-0.12-1.fc9.i386
kernel-devel-2.6.27.25-78.2.56.fc9.i686
kernel-2.6.25-14.fc9.i686
kernel-headers-2.6.27.25-78.2.56.fc9.i386
kernel-2.6.27.25-78.2.56.fc9.i686
kernel-firmware-2.6.27.25-78.2.56.fc9.noarch

[q.yang@localhost sierra_drv_1.7.32]$ rpm -qa|grep kernel |grep devel
kernel-devel-2.6.27.25-78.2.56.fc9.i686

[q.yang@localhost sierra_drv_1.7.32]$ rpm -qa|grep kernel |grep headers
kernel-headers-2.6.27.25-78.2.56.fc9.i386

[root@localhost sierra_drv_1.7.32]# yum install kernel-devel-2.6.25-14.fc9.i686
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.i686 0:2.6.25-14.fc9 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
kernel-devel i686 2.6.25-14.fc9 fedora 5.1 M

Transaction Summary
====================================================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 5.1 M
Is this ok [y/N]: y
Downloading Packages:
kernel-devel-2.6.25-14.fc9.i686.rpm | 5.1 MB 00:21
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : kernel-devel 1/1

Installed:
kernel-devel.i686 0:2.6.25-14.fc9

Complete!


/*********************************/
/* Vi Relevant */
/* Created: 2007-Aug-16 THU */
/* Update: 2007-Aug-20 MON */
/* */
/* v0.0.0.1 added Yum relevant commands 2008-SEP-26 FRI */
/* v0.0.0.2 added vnc relevant commands 2008-SEP-27 SAT */
/* v0.0.0.3 added svn relevant commands 2008-OCT-01 WED */
/**********************************************************************/



DISPLAY DISK USAGE
------------------------------------------------------------------
[q.yang@localhost ~]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6063688 5204096 551576 91% /
/dev/sda6 194442 18921 165482 11% /boot
tmpfs 224740 96 224644 1% /dev/shm
gvfs-fuse-daemon 6063688 5204096 551576 91% /home/q.yang/.gvfs
[q.yang@localhost ~]$ su
Password:
[root@localhost q.yang]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6063688 5204100 551572 91% /
/dev/sda6 194442 18921 165482 11% /boot
tmpfs 224740 96 224644 1% /dev/shm
[root@localhost q.yang]#



WHICH LINUX KERNEL TO BOOT
------------------------------------------------------------
[root@localhost kernel]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,5)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=2
timeout=5
splashimage=(hd0,5)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.27.25-78.2.56.fc9.i686)
root (hd0,5)
kernel /vmlinuz-2.6.27.25-78.2.56.fc9.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.27.25-78.2.56.fc9.i686.img
title Linux (2.6.25-14.fc9.i686)
root (hd0,5)
kernel /vmlinuz-2.6.25-14.fc9.i686 ro root=UUID=916c799e-4ae5-4820-8de6-0bbc5b7b8968 rhgb quiet
initrd /initrd-2.6.25-14.fc9.i686.img
title Win2000
rootnoverify (hd0,0)
chainloader +1

[root@localhost kernel]# ll /boot/
total 12767
-rw-r--r-- 1 root root 86348 2008-05-01 20:34 config-2.6.25-14.fc9.i686
-rw-r--r-- 1 root root 90947 2009-06-19 02:57 config-2.6.27.25-78.2.56.fc9.i686
drwxr-xr-x 3 root root 1024 2010-06-04 02:19 efi
drwxr-xr-x 2 root root 1024 2010-06-07 14:42 grub
-rw------- 1 root root 3294836 2010-06-04 02:21 initrd-2.6.25-14.fc9.i686.img
-rw------- 1 root root 3326324 2010-06-07 14:42 initrd-2.6.27.25-78.2.56.fc9.i686.img
drwx------ 2 root root 12288 2010-06-04 02:11 lost+found
-rw-r--r-- 1 root root 892575 2008-05-01 20:34 System.map-2.6.25-14.fc9.i686
-rw-r--r-- 1 root root 976362 2009-06-19 02:57 System.map-2.6.27.25-78.2.56.fc9.i686
-rwxr-xr-x 1 root root 2088288 2008-05-01 20:34 vmlinuz-2.6.25-14.fc9.i686
-rwxr-xr-x 1 root root 2227280 2009-06-19 02:57 vmlinuz-2.6.27.25-78.2.56.fc9.i686




FIND COMMAND USAGE
-----------------------------
Only find current directory without search sub-dir using '-maxdepth 1'
[q.yang@localhost ProjProgrammingTest]$ find ./include/ -maxdepth 1 -name '*' |grep .h
./include/Misc.h
./include/CommsLinkSessionManager.h
./include/Gpio.h
./include/GsnDataTypes.h
./include/DeviceTcpTx.h
./include/CommsMain.h
./include/Stack61850.h
./include/StackSpac.h
./include/StackDnp3.h
./include/StackGserver.h


[qyang@pc6de4 ~/ns-allinone-2.28]$ find . -name "n?.*" -print under tcsh&bash
./tk8.4.5/library/msgs/nl.msg
./lib/tk8.4/msgs/nl.msg
./ns-2.28/ns-tutorial/ns.html
./ns-2.28/diffusion3/lib/nr/nr.cc
./ns-2.28/diffusion3/lib/nr/nr.o
./ns-2.28/diffusion3/lib/nr/nr.hh
./ns-2.28/doc/ns.bib
./ns-2.28/ns.1

find . -wholename './.metadata' -prune -o -print //exclude certain directory
find . ! -name '*.class' //exclude certain file pattern

[q.yang@localhost ProjProgrammingTest]$ find ./include/ -maxdepth 1 -name '*.h' -exec wc {} \;
line words characters
42 87 968 ./include/Misc.h
131 414 4487 ./include/CommsLinkSessionManager.h


DELETE ALL FOLDERS WITH CERTAIN NAME PATTERN
---------------------------------------------------
[q.yang@localhost ltib-qs]$ find . -noleaf -name '.svn' -exec rm -r -f {} \;

FIND STRING IN ALL CERTAIN FILES
------------------------------------------------------------
First one can show line number
[q.yang@localhost ltib-qs]$ fd "*.*con*" -print0 | xargs -0 grep MODLIST -rn
./config/profile/swang.config:301:CONFIG_SYSCFG_MODLIST=""
./config/profile/swang-poc.config:307:CONFIG_SYSCFG_MODLIST=""
./config/platform/phy3250/ChkGsnMake_Config.config:455:CONFIG_SYSCFG_MODLIST=""
./config/platform/phy3250/GsnMake.config:455:CONFIG_SYSCFG_MODLIST=""
./config/platform/phy3250/GsnMake.config.old:455:CONFIG_SYSCFG_MODLIST=""
./config/platform/phy3250/.config:455:CONFIG_SYSCFG_MODLIST=""
./config/platform/phy3250/RoofsToNAND_Flash.config:455:CONFIG_SYSCFG_MODLIST=""

This cannot show line number but just the string result after search

[q.yang@localhost Documentation]$ grep endpoint . -r *.txt
./MSI-HOWTO.txt:PCI Express endpoints uses INTx emulation (in-band messages) instead
./input/yealink.txt:A: The sysfs files are located on the particular usb endpoint. On most
./sound/alsa/Audiophile-Usb.txt:parse_audio_endpoints function uses a quirk called
./sound/alsa/soc/dapm.txt:An endpoint is a start or end point (widget) of an audio signal within the
./sound/alsa/soc/dapm.txt:snd_soc_dapm_set_endpoint(codec, "Widget Name", 0);



FIND YUM PACKAGE BY KEY WORDS
---------------------------
[root@localhost q.yang]# yum search ppp


CHANGE ALL FOLDERS/FILES OWNERSHIP (user,group)
--------------------------------------------------
[q.yang@localhost ltib-qs]$ chown -c -R q.yang:q.yang .


LIST FILE SORTED BY TIME
------------------------------------------
[q.yang@localhost lpc3250]$ ls -lt ltib-qs/config/platform/phy3250/




//-------------------------------
//php+apache+msql installation
//
[root@QuentinFedoraHome q.yang]# rpm -qa | grep mysql
mysql-connector-java-3.1.12-5.fc9.i386
mysql-libs-5.0.51a-1.fc9.i386
[root@QuentinFedoraHome q.yang]# rpm -qa | grep httpd
httpd-tools-2.2.8-3.i386
httpd-2.2.8-3.i386
[root@QuentinFedoraHome q.yang]# rpm -qa | grep php
[root@QuentinFedoraHome q.yang]#



//------------------------------
//Svn relevant commands
//




Now, you use svn merge to replicate your branch changes back into the trunk.
$ pwd
/home/user/calc-trunk
$ svn update # (make sure the working copy is up to date)
At revision 390.
$ svn merge --reintegrate http://svn.example.com/repos/calc/branches/my-calc-branch
--- Merging differences between repository URLs into '.':
U button.c
U integer.c
U Makefile
U .
$ # build, test, verify, ...
$ svn commit -m "Merge my-calc-branch back into trunk!"
Sending .
Sending button.c
Sending integer.c
Sending Makefile
Transmitting file data ..
Committed revision 391.

[q.yang@QuentinFedoraHome ~]$ ssh-keygen -b 1024 -t dsa -N passphrase -f
keyfileGenerating public/private dsa key pair.
Your identification has been saved in keyfile.
Your public key has been saved in keyfile.pub.
The key fingerprint is:
50:81:da:e8:e9:b1:11:ec:f6:89:ac:3c:cf:a8:bd:05 q.yang@QuentinFedoraHome
[q.yang@QuentinFedoraHome ~]$ ls -l keyfile*
-rw------- 1 q.yang q.yang 744 2008-10-01 17:20 keyfile
-rw-r--r-- 1 q.yang q.yang 614 2008-10-01 17:20 keyfile.pub

http://tortoisesvn.net/ssh_howto

[q.yang@QuentinFedoraHome ~]$ svn list file:///var/svn/repos_personal/Doc_Documents
[q.yang@QuentinFedoraHome ~]$ svn import ~/Doc_Documents file:///var/svn/repos_personal/Doc_Documents -m "Initial import"

[q.yang@QuentinFedoraHome Svn_Repositories]$ svn checkout svn://10.1.1.7/var/svn/repos_personal/

$ svnadmin create /var/svn/newrepos

//-------------------------------------------
//Samba
//

[root@QuentinFedoraHome q.yang]# service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@QuentinFedoraHome q.yang]# chkconfig smb on
[root@QuentinFedoraHome q.yang]# system-config-users

[root@QuentinFedoraHome q.yang]# yum install system-config-samba

system-config-services gui services management

//-------------------------------------------
// VNC server in linux
//

#chkconfig vncserver on

#service vncserver restart

VNCSERVERS="1:q.yang 2:m.xie"
VNCSERVERARGS[1]="-geometry 1024x768 "
VNCSERVERARGS[2]="-geometry 800x600 "


[root@QuentinFedoraHome q.yang]# vi /etc/sysconfig/vncservers

[q.yang@QuentinFedoraHome Code_Shells]$ vncserver -kill:2

[tchung@tchung101 tchung]$ sudo /sbin/service iptables restart restart firewall


[root@QuentinFedoraHome Code_Shells]# vi /etc/sysconfig/iptables change firewall


#rpm -q vnc vnc-server

//-------------------------------------------
//user management chgrp,chown,useradd,passwd,chmod
//

[root@QuentinFedoraHome q.yang]# groupadd admin
[root@QuentinFedoraHome q.yang]# groupadd master
[root@QuentinFedoraHome q.yang]# groupadd family
[root@QuentinFedoraHome q.yang]# groupadd users
groupadd: group users exists


[root@QuentinFedoraHome q.yang]# vi /etc/default/useradd
[root@QuentinFedoraHome q.yang]# vi /etc/group


CHANGE USER'S GROUP
------------------------
[root@QuentinFedoraHome q.yang]# usermod -g admin -G users,family,master q.yang


[root@QuentinFedoraHome svn]# chmod 711 -R repos_personal/
[root@QuentinFedoraHome svn]# ll repos_personal/db/
total 28
-rwx--x--x 1 root root 6 2008-10-03 09:20 current
-rwx--x--x 1 q.yang root 2 2008-09-28 23:22 format
-rwx--x--x 1 q.yang root 5 2008-09-28 23:22 fs-type
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 revprops
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 revs
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 transactions
-rwx--x--x 1 q.yang root 37 2008-09-28 23:22 uuid
-rwx--x--x 1 q.yang root 0 2008-09-28 23:22 write-lock
[root@QuentinFedoraHome svn]# man chown
[root@QuentinFedoraHome svn]# man chown
[root@QuentinFedoraHome svn]# chown -R q.yang repos_personal/
[root@QuentinFedoraHome svn]# ll repos_personal/db/
total 28
-rwx--x--x 1 q.yang root 6 2008-10-03 09:20 current
-rwx--x--x 1 q.yang root 2 2008-09-28 23:22 format
-rwx--x--x 1 q.yang root 5 2008-09-28 23:22 fs-type
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 revprops
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 revs
drwx--x--x 2 q.yang root 4096 2008-10-03 09:20 transactions
-rwx--x--x 1 q.yang root 37 2008-09-28 23:22 uuid
-rwx--x--x 1 q.yang root 0 2008-09-28 23:22 write-lock


[root@QuentinFedoraHome svn]# ll
total 8
drwx--x--x 7 q.yang root 4096 2008-09-28 23:22 repos_personal
drwxrwxr-x 7 q.yang root 4096 2008-09-28 22:48 repos_projects
[root@QuentinFedoraHome svn]# chgrp -R 100 repos_projects/
[root@QuentinFedoraHome svn]# ll
total 8
drwx--x--x 7 q.yang root 4096 2008-09-28 23:22 repos_personal
drwxrwxr-x 7 q.yang users 4096 2008-09-28 22:48 repos_projects


[root@bigdog /root]# useradd blarg add account
[root@bigdog /root]# passwd blarg set pwd or change pwd(when user logged in)


yum list updates
yum update update system
yum list selinux-policy*

[root@blackrock .vnc]# yum list selinux-policy*
Loaded plugins: refresh-packagekit
Installed Packages
selinux-policy.noarch 3.3.1-55.fc9 installed
selinux-policy-devel.noarch 3.3.1-55.fc9 installed
selinux-policy-targeted.noarch 3.3.1-51.fc9 installed
Available Packages
selinux-policy-mls.noarch 3.3.1-51.fc9 updates

[root@blackrock /]# more ~topping/.vnc/blackrock.orb.org:1.log




:file ;display current file name
:set wrap ;wrap text
:set nowrap ;don't wrap text when display
:set winwidth ;set where to wrap text when editing file

cp [-drsu] u is used for update of file used for backup

/etc/rc.d/init.d ./smb start ./smb stop ./smb restart
$cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd ; then delete all other password lines
smbpasswd -a QuentinYANG ; add samba password for user QuentinYANG
testparm ;test samba service from smb.conf
smbclient -L localhost ;list samba service on localhost or other ip address

ifconfig eth0 10.0.0.23

df -h list disk occupacy infor
du -s
rpm -q -a > /home/packages.log
rpm -ivf --nodeps --force
grep hp /home/packages.log
grep instance . -R -recursive searching subdirectories
grep -i -r --include=*.txt Q: ~/Doc_PdfTxtHtm/ -i means ignor the case, --include, --exclude=PATTERN means can search only some files with such a PATTER
grep timer . -r *.java (is a simple way to serch some text pattern like "timer" in all *.java files of all subdirectories)
egrep -i 'Average | x ' ~/driver_heartbeat_debug_01.log '|' means, match either pattern, here we have to use egrep for extend searching
egrep "id\(\<$NodeId\>|\<$NodeId2\>|\<$NodeId3\>" temp.log > temp1.log
rpm -e scim scim-tables scim-chewing
rpm -q scim -i


nmap -v 130.130.10.126
/sbin/ifconfig list ip address
route

ps -aux | grep pdf list all process
kill 19862 kill process with pid

ls -D all
ll -cX ./Doc_PdfTxtHtm/ -c means sort by file name, time,-X by file extention
ll -t ./Doc_PdfTxtHtm/ -t sort by file change time

# learn wht is the different of single quotation mark and double quotation mark
# and how to search two types of files with different extention name at the
# same time
echo "fd "*.*" |egrep '*.jpy|*.bsh'" >> ~/Doc_PdfTxtHtm/linux_commandlist.txt
fd *.* |egrep '*.jpy|*.bsh'
echo "fd '"*.*"' |egrep '*.jpy|*.bsh'" >> ~/Doc_PdfTxtHtm/linux_commandlist.txt
fd '*.*' |egrep '*.jpy|*.bsh'
echo "fd \"*.*\" |egrep '*.jpy|*.bsh'" >> ~/Doc_PdfTxtHtm/linux_commandlist.txt
fd "*.*" |egrep '*.jpy|*.bsh'
ln -s ~/Doc_PdfTxtHtm/link_list.txt .
mv -v * ~/MyMac/
fd *.jar -exec jar tvf {} \; |grep InputStreamReader
fd "*.java" -mtime -5
touch eclipseMyMac.tar
fd "*.java" -mtime -5 -exec tar -uvf eclipseMyMac.tar {} \;
grep "found neighbour:" . -r -n *.java // search string pattern in *.java files under all subdirectories and printout line number in that file as well
fd "*.java" -print0 | xargs -0 grep log -rn //search string pattern in files generated from file search result
find . -wholename './.metadata' -prune -o -print //exclude certain directory
find . ! -name '*.class' //exclude certain file pattern
fd "*.java" -mtime -8 -exec ls -all -ct {} \; // search files changed over last 8 days and list their time stamp and sorted by changed time

date +%g%m%d%H //06100123 yymmddhh date shell
#uname -r or #rpm -q kernel //list the kernel version

. logAnalysis.sh 16 ringInfo16135050_appcw1000.log | cut -d" " -f1 //cut -d define what symbole is used to seperate input string. -f define what field to print, 1st or 2nd after cutting.

. logAnalysis.sh 16 ringInfo16135050_appcw1000.log | cut -d" " -f1 | uniq -c | sort -rn
// uniq -c will count number of repeat times of same patten lines. sort -rn
// sort all lines according to the number of repeat times.

cscope
find /home/quentin/eclipse_workspace/MyMac/src/ -name "*.java" > ~/eclipse_workspace/MyMac/src/cscope.files

cscope -b
cscope -R

ctags -n -f cppcomplete.tags --fields=+ai --C++-types=+p * -L cscope.files
cvs -d /usr/local/newrepos init //create repository in path /usr/local/newrepos

cvs import -d -m "initial import into CVS from eclipse MyMac on Mimir" MyMacProj quentin start //-d option to keep modified time CVS_ROOT already set up, so import to CVS root directory, import files to repository, execute this command on top level of ur project folder which u want to add to repository

cvs checkout MyMacProj //check out one work copy in the folder u want to edit

cvs status ./src/jist/swans/app/AppRingschedule.java
cvs log ./src/jist/swans/app/AppRingschedule.java
cvs ci -m"back to the stage passing growth of tree"
cvs update

cvs -q tag Release-2006_09_30 // add tag to all files at their current version
cvs -q tag Release-2006_10_06-AdditiveRadioSNR
cvs tag Backup-2006_10_11-HalfwayStartScheduling ./src/jist/swans/mac/MacCsmaCa.java



cvs co -r Release-2006_09_30 MyMacProj //check out a work copy based on one tag "Release-2006_09_30"

cvs update -r Release-2006_09_30 // get a snapshot of one version with tag, without checkout all the files
cvs update -d // run update with the -d flag, telling it to bring down any new directories from the repository.
cvs update -P // prune useless directiories
cvs status ./src/driver/ringschedule.java //check on file status, u can see the Sticky Tag: Release-2006_09_30 (revision: 1.1.1.1)
cvs -q update -A ./src/driver/ringschedule.java // release the sticky state of one file so that get the latest version of this file

cvs -d:pserver:anon@jist.ece.cornell.edu:/cvs-jist login

cvs -d:ext:quentin@mimir.snrc.uow.edu.au:/home/quentin/CvsMyMac login
cvs -Q update -p -r 1.3 hello.c > hello.c //reverse to previous version

yarkon$ cvs add newfile.c //add files
yarkon$ cvs ci -m "added newfile.c" newfile.c

yarkon$ mkdir c-subdir
yarkon$ cvs add c-subdir

yarkon$ rm newfile.c //remove files
yarkon$ cvs remove newfile.c
yarkon$ cvs ci -m "removed newfile.c" newfile.c

yarkon$ rm file1 file2 file3 //remove directories
yarkon$ cvs remove file1 file2 file3
yarkon$ cvs ci -m "removed all files" file1 file2 file3
yarkon$ cd ..
yarkon$ cvs update -P

yarkon$ mv oldname newname //rename files
yarkon$ cvs remove oldname
yarkon$ cvs add newname
yarkon$ cvs ci -m "renamed oldname to newname" oldname newname

yarkon$ mkdir newdir //rename directories
yarkon$ cvs add newdir
yarkon$ mv olddir/* newdir
yarkon$ cd olddir
yarkon$ cvs rm foo.c bar.txt
yarkon$ cd ../newdir
yarkon$ cvs add foo.c bar.txt
yarkon$ cd ..
yarkon$ cvs commit -m "moved foo.c and bar.txt from olddir to newdir"
yarkon$ cvs update -P



ls . -R -D | grep /CVS | cut -d ":" -f1



////////////////////////////////////////////////////////////////////////
// Quentin study notes for unix
// focus on the command list in unix
// time History Author
// 6/9/2004 Created Quentin.YANG
// 17/8/2005 update in UOW Quentin.YANG
add vi guide;
// 18/8/2005 add web resource section Quentin.YANG
looking for LaTax-article
editing tool
// 25/8/2005 add linux config guide(CN)
// add Bash section
// add emacs section
// 20/6/2006 how to create own shell
//
//
// 29/6/2006 command combination list
///////////////////////////////////////////////////////////////////////

[root @test /root ]# cp [-drsu] [来源档] [目的档]
参数说明:
-d     :在进行 copy 的时候,如果是 copy 到 link 档案,若不加任何参数,则预设情
况中会将 link 到的源文件copy 到目的地,若加 -d 时,则 link 档案可原封不动的将 link 这个
快捷方式其拷贝到目的地!
-r     :可以进行目录的 copy 呦!
-s :做成连结档,而不 copy 之意!与 ln 指令相同功能!
-u, --update:如果来源档比较新,或者是没有目的档,那么才会进行 copy 的动作!可用于备
份的动作中


q: Rename directory? --wht unix command? A: just use mv
Q: wht is the difference between gzip and zip/unzip? //gzip -v -d abcd.gz
Alias? alias is set up in ~/.bashr
Q: How to recover files in Linux? How do use trash in linux?





如何查看硬件的芯片??
[root@linuxsir01 root]# lspci -v
要说明系统、版本以及内核的版本,用下面的命令来测试,
#uname –a

linux version:
/etc/redhat-release

新手有时对vi vim emacs 不太熟悉,这需要更适合新手用的文本编辑器。比如GNOME中的 gedit ,KDE中的kwrite或者kate等。
如果您用KDE或者GNOME,发行版中都有 gedit 或者kwrite,也应该有xedit 。
如果您是初学Linux,只是想找一些象Windows写字板那样简单功能的编辑器,leafpad 和mousepad足够用。如果在linux text模式下操作,不会用vi或者vim的情况下,用nano修改文件也是足够了。
本帖专为新手准备,希望能对初学Linux的弟兄有所帮助。


rpm -qa | grep vnc


把上面那些rpm都DOWN下来到一个文件夹。。。然后在控制台下输入:
#cd [你DOWN下RPM的文件夹]
#rpm -ivh *.rpm

rpm install, pacage management, refer to man rpm
这样全都OK了。。。。

兄弟,请看!
ftp://ftp.gtk.org/pub/gtk/v2.0/binary/old/RedHat-7.2/RPMS/i386/
rpm安装最简单。。。。。试一下吧。。有问题再发帖。。。
不要急,这就是学习。。。

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

qepafrps02-06-21, 21:35
是呀,这里都是.rpm,不过很多呀,是不是还是把gtk,atk,glib,pango,这几个下了,一个一个的安呀,难道没有一个总的.rpm的那种吗?

========================= command combination list ===========================
$ls -all | less
$ls -all | grep .jar
$ls -all -R | grep .jar
$su temporary change user, default change to root so that having right to install software

=========== how to create own shell to backup personal files================



# fgrep bball etc/passwd
bball : x : 100 : 100 : William H. Ball , , , , : /home/bball : /bin/bash

==========Bash============================

bash的内建叁数很多,你可以自行"man bash"查一查。这里我只说明一些常用

及重要的。


PPID : 该bash的呼叫者process ID.


PWD : 目前的工作目录。


OLDPWD : 上一个工作目录。


HOSTTYPE : 机器种类。


OSTYPE : 作业系统名称。


PATH : 命令搜寻路径。



PATH="/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:."
发帖时间: 02-12-15, 02:58
查看系统环境变量的方法是用set,这是在bash下的。
[root@linuxsir01 root]# set
大熊宝宝说的也是一个方法,这个方法写入后,就不会使变量设置重新启动后丢失。
也可以这样做。。
改用户目录下的.bashrc
加入
PATH="$PATH:/tmp"




_____________________________________
请弟兄们发帖时要写个好标题,多谢!
签名不支持html和bbcode,请弟兄为了版面的整洁,请更改签名档,谢谢!
请各版版主及初学Linux的弟兄,请在您的签名写上机器的配置,以及您所用的系统(包装版本号,内核),谢谢。

Slackintosh 10.1+kernel-2.6.11.8+xfce-4.2.1.1
=====================================
帮助那些需要帮助的人── 吾师语录
世上没有踏不平的山,只有走不完的路!── 师兄语录


HOME : 目前使用者的home directory



Section=========emacs,==============================
C means Ctl key, M means Alt key;
control cursor C-p,C-n,C-b,C-f;M-f;(move by words) C-l center the text to your cursor;
C-a,C-e; move the start and end of one line;

C-h w command - to check which key bind to the command
;; C-h k key - to check which command the key bind to
;; C-j - run the lisp command(put the cursor at end)
;;
;; C-c C-t - change mode to hungry-state and auto-state
;; C-c C-a - change mode to auto-state
;; C-c C-d - change mode to hungry-state
;; C-c C-e - expand macro
;; C-c C-\ - add '\' at then end of the line
;; C-u C-s - regular expression search
;; C-x 5 2 - open new frame
;; C-x 5 0 - close new frame
;;
;; M-; - insert a comment
;; M-\ - fixup whitespace
;; M-/ - auto complete the word
;; M-l - downcase-word
;;
;; Mark the region, then
;;
;; C-x r k - kill rectangle
;; C-x r t - insert word in columns


C-x C-f :打开/新建文件
C-x S :保存所有缓冲区文件
C-x C-v:在当前缓冲区打开文件
C-x k :关闭当前缓冲区
C-x i : 在当前光标位置插入文件
M-x replace-string: 一次性替换字符串
M-x % : 循环替换。
C-s
C-r :查询

C-@ :设置标记,然后选取
C-w :相当于剪切。
M-w :相当于复制
C-y :粘贴
M-y : 循环粘贴。

C-o:开新行

C-f, C-b, C-p, C-n, M-f, M-b, C-v , M-v , C-l, M-< 移动。M->,


C - !, 一次性执行shell, M-x shell, 启动shell外壳。
M-x compile:编译程序。



Under cygwin, C-x,C-c does not work to exit emacs; have to press F10, then f,e to exit emacs; Also, C-h,C-t does not enter tutorial, Try to use F1 and then option ? then "t", emacs tutorial;



Section ======unix=========================================================
after ns2 install

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

Please put /home/qyang/ns-allinone-2.28/bin:/home/qyang/ns-allinone-2.28/tcl8.4.5/unix:/home/qyang/ns-allinone-2.28/tk8.4.5/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /home/qyang/ns-allinone-2.28/otcl-1.9, /home/qyang/ns-allinone-2.28/lib,
into your LD_LIBRARY_PATH environment variable.
If it complains about X libraries, add path to your X libraries
into LD_LIBRARY_PATH.
If you are using csh, you can set it like:
setenv LD_LIBRARY_PATH
If you are using sh, you can set it like:
export LD_LIBRARY_PATH=

(2) You MUST put /home/qyang/ns-allinone-2.28/tcl8.4.5/library into your TCL_LIBRARY environmental
variable. Otherwise ns/nam will complain during startup.

(3) [OPTIONAL] To save disk space, you can now delete directories tcl8.4.5
and tk8.4.5. They are now installed under /home/qyang/ns-allinone-2.28/{bin,include,lib}

After these steps, you can now run the ns validation suite with
cd ns-2.28; ./validate

For trouble shooting, please first read ns problems page
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.






gunzip,unzip,tar;if forget the option can use "$tar --help"
Ctr+C;terminate process;
edit ~/.bashrc,set your ENV;

try to find the path of some command by "where" only availabe under Tcsh
[qyang@pc6de4 ~]$ where is tcsh
---/bin/tcsh
[qyang@pc6de4 ~]$ pwd
/home/qyang
[qyang@pc6de4 ~]$ ls /
bin dev home lib misc opt root selinux tmp var
boot etc initrd lost+found mnt proc sbin sys usr
[qyang@pc6de4 ~]$ ls /bin
arch cpio env kill netstat sed traceroute
ash csh ex link nice setfont traceroute6
ash.static cut false ln nisdomainname setserial true
aumix-minimal date fgrep loadkeys pgawk sh umount
awk dd gawk login ping sleep uname
basename df gettext ls ping6 sort unicode_start
bash dmesg grep mail ps stty unicode_stop
bash2 dnsdomainname gtar mkdir pwd su unlink
bsh doexec gunzip mknod red sync usleep
cat domainname gzip mktemp rm tar vi
chgrp dumpkeys hostname more rmdir tcsh view
chmod echo igawk mount rpm touch ypdomainname
chown ed ipcalc mt rvi tracepath zcat
cp egrep kbd_mode mv rview tracepath6
[qyang@pc6de4 ~]$ emacs
[qyang@pc6de4 ~]$ wher is emacs
wher: Command not found.
[qyang@pc6de4 ~]$ where is emacs
---/usr/bin/emacs



Section--from /for_unix_beginner/-----
--% echo $OSTYPE
USER (your login name)
HOME (the path name of your home directory)
HOST (the name of the computer you are using)
ARCH (the architecture of the computers processor)
DISPLAY (the name of the computer screen to display X windows)
PRINTER (the default printer to send print jobs)
PATH (the directories the shell should search to find a command)
setenv; printenv or env; unsetenv; ENVIRONMENT variables are set using the command, displayed using the commands, and unset using the command
--% printenv | less show all values of these variables, type |less can not work in Cygwin

--% set | less To show all values of these variables, type |less can not work in Cygwin

--The C and TC shells uses two files called .login and .cshrc (note that both file names begin with a dot).Information in these files is used to set up your working environment.

% set history = 200
% echo $history
To PERMANENTLY set the value of history, you will need to add the set command to the .cshrc file
% nedit ~/.cshrc
% source .cshrc Save the file and force the shell to reread its .cshrc file buy using the shell source command

% "set path = ($path ~/units174/bin)" add it to the end of your existing path (the $path represents this) by issuing the command can't work under unix bash; can work after chang it to "export PATH=($PATH ~/units174/bin)"
% cd; pwd HINT: You can run multiple commands on one line by separating them with a semicolon.


Section----shortcut key--------
right click to paste;



Section=================----vi------------------
一、Unix编辑器概述

编辑器是使用计算机的重要工具之一,在各种操作系统中,编辑器都是必不可少的部件。Unix及其相似的ix操作系统系列中,为方便各种用户在各个不同的环境中使用,提供了一系列的ex编辑器,包括 ex, edit,ed 和vi.其中ex,edit,ed都是行编辑器,现在已很少有人使用,Unix提供他们的原因是考虑到满足各种用户特别是某些终端用户的需要。

值得庆幸的是,Unix提供了全屏幕的Vi编辑器,这使我们的工作轻松不少。不少DOS用户抱怨Vi编辑器不象DOS下的编辑器如edit那么好用,这是因为Vi考虑到各种用户的需要,没有使用某些通用的编辑键(在各个不同的终端机上他们的定义是不同的,在某些终端机上甚至没有这些键)。而是采用状态切换的方法,但这只是习惯的问题,一旦你熟练的使用上了vi你就会觉得它其实也很好用。虽然 Vi采用了状态切换的方法,但电脑的硬件及操作系统多种多样,某些电脑的键盘上没有特定的几个功能键!那麽不就有某些功能不能用了?这个问题在 Unix 系统上也一样,几乎各大电脑厂商都有自己的Unix 系统,而 vi 的操作方法也会随之有点出入。这里我们采用 PC 的键盘来说明 vi 的操作,但在具体的环境中还要参考相应的资料,这一点是值得注意的。

二、Vi入门

(一)、进入vi

在系统提示字符(如$、#)下敲入vi <档案名称>,vi 可以自动帮你载入所要编辑的文件或是开启一个新文件(如果该文件不存在或缺少文件名)。进入 vi 后萤幕左方会出现波浪符号,凡是列首有该符号就代表此列目前是空的。

(二)、两种模式

如上所述,vi存在两种模式:指令模式和输入模式。在指令模式下输入的按键将做为指令来处理:如输入a,vi即认为是在当前位置插入字符。而在输入模式下,vi则把输入的按键当作插入的字符来处理。指令模式切换到输入模式只需键入相应的输入命令即可(如a,A),而要从输入模式切换到指令模式,则需在输入模式下键入ESC键,如果不晓得现在是处於什麽模式,可以多按几次 [ESC],系统如发出哔哔声就表示已处于指令模式下了。

付:有指令模式进入输入模式的指令:

新增 (append)

a :从光标所在位置後面开始新增资料,光标後的资料随新增资料向後移动。

A: 从光标所在列最後面的地方开始新增资料。

插入 (insert)

i: 从光标所在位置前面开始插入资料,光标後的资料随新增资料向後移动。

I :从光标所在列的第一个非空白字元前面开始插入资料。

开始 (open)

o :在光标所在列下新增一列并进入输入模式。

O: 在光标所在列上方新增一列并进入输入模式。

(三)、退出vi

在指令模式下键入:q,:q!,:wq或:x(注意:号),就会退出vi。其中:wq和:x是存盘退出,而:q是直接退出,如果文件已有新的变化,vi会提示你保存文件而:q命令也会失效,这时你可以用:w命令保存文件后再用:q退出,或用:wq或:x命令退出,如果你不想保存改变后的文件,你就需要用:q!命令,这个命令将不保存文件而直接退出vi。

(四)、基本编辑

配合一般键盘上的功能键,像是方向键、[Insert] 、[Delete] 等等,现在你应该已经可以利用 vi 来编辑文件了。当然 vi 还提供其他许许多多功能让文字的处理更为方便。

何谓编辑?一般认为是文字的新增、修改以及删除,甚至包括文字区块的搬移、复制等等。先这里介绍 vi的如何做删除与修改。(注意:在 vi 的原始观念里,输入跟编辑是两码子事。编辑是在指令模式下操作的,先利用指令移动光标来定位要进行编辑的地方,然後才下指令做编辑。)

删除与修改文件的命令:

x: 删除光标所在字符。

dd :删除光标所在的列。

r :修改光标所在字元,r 後接著要修正的字符。

R: 进入取替换状态,新增文字会覆盖原先文字,直到按 [ESC] 回到指令模式下为止。

s: 删除光标所在字元,并进入输入模式。

S: 删除光标所在的列,并进入输入模式

其实呢,在PC上根本没有这麽麻烦!输入跟编辑都可以在输入模式下完成。例如要删除字元,直接按[Delete] 不就得了。而插入状态与取代状态可以直接用 [Insert] 切换,犯不著用什麽指令模式的编辑指令。不过就如前面所提到的,这些指令几乎是每台终端机都能用,而不是仅仅在 PC 上。
在指令模式下移动光标的基本指令是 h, j, k, l 。想来各位现在也应该能猜到只要直接用 PC 的方向键就可以了,而且无论在指令模式或输入模式下都可以。多容易不是。
当然 PC 键盘也有不足之处。有个很好用的指令 u 可以恢复被删除的文字,而 U 指令则可以恢复光标所在列的所有改变。这与某些电脑上的 [Undo] 按键功能相同。
三、附件:vi详细指令表
(一)、基本编辑指令:
新增 (append)

a :从光标所在位置後面开始新增资料,光标後的资料随新增资料向後移动。

A: 从光标所在列最後面的地方开始新增资料。

插入 (insert)

i: 从光标所在位置前面开始插入资料,光标後的资料随新增资料向後移动。

I :从光标所在列的第一个非空白字元前面开始插入资料。

开始 (open)

o :在光标所在列下新增一列并进入输入模式。

O: 在光标所在列上方新增一列并进入输入模式。

x: 删除光标所在字符。

dd :删除光标所在的列。

r :修改光标所在字元,r 後接著要修正的字符。

R: 进入取替换状态,新增文字会覆盖原先文字,直到按 [ESC] 回到指令模式下为止。

s: 删除光标所在字元,并进入输入模式。

S: 删除光标所在的列,并进入输入模式。

(二)、光标移动指令:
由於许多编辑工作是藉由光标来定位,所以 vi 提供许多移动光标的方式,这个我们列
几张简表来说明(这些当然是指令模式下的指令):

指令 说明  功能键
0 移动到光标所在列的最前面 [Home]
$  移动到光标所在列的最後面 [End]
[CTRL][d] 向下半页  [PageDown]
[CTRL][f] 向下一页
[CTRL][u] 向上半页
[CTRL][b] 向上一页 [PageUp]

指令 说明
H 移动到视窗的第一列
M 移动到视窗的中间列
L 移动到视窗的最後列
b 移动到下个字的第一个字母
w 移缴细鲎值牡谝桓鲎帜?nbsp; 
e 移动到下个字的最後一个字母
^ 移动到光标所在列的第一个非空白字元

指令 说明 
n- 减号移动到上一列的第一个非空白字元前面加上数字可以指定移动到以上 n 列
n+ 加号移动到下一列的第一个非空白字元前面加上数字可以指定移动到以下 n 列
nG 直接用数字 n 加上大写 G 移动到第 n 列
指令 说明
fx
往右移动到 x 字元上
Fx 往左移动到 x 字元上 
tx 往右移动到 x 字元前
Tx 往左移动到 x 字元前
; 配合 f&t 使用,重复一次
, 配合 f&t 使用,反方向重复一次
/string 往右移动到有 string 的地方
?string 往左移动到有 string 的地方
n  配合 /&? 使用,重复一次
N  配合 /&? 使用,反方向重复一次

指令 说明 备注
n(
左括号移动到句子的最前面句子是以前面加上数字可以指定往前移动 n 个句子 ! . ? 三种符号来界定
n) 右括号移动到下个句子的最前面前面加上数字可以指定往後移动 n 个句子 ! . ? 三种符号来界定
n{  左括弧移动到段落的最前面 段落是以段落间的空白列界定
n} 前面加上数字可以指定往前移动 n 个段落右括弧移动到下个段落的最前面前面加上数字可以指定往後移动 n 个段落 段落是以段落间的空白列界定


(三)、更多的编辑指令
这些编辑指令非常有弹性,基本上可以说是由指令与范围所构成。例如 dw 怯缮境噶?nbsp;d 与范围 w 所组成,代表删除一个字 d(elete) w(ord) 。
指令列表如下:
d 删除(delete)
y 复制(yank)
p 放置(put)
c 修改(change)
范围可以是下列几个:
e 光晁谖恢玫礁米值淖钺嵋桓鲎帜?br> w 光标所在位置到下个字的第一个字母
b 光标所在位置到上个字的第一个字母
$ 光标所在位置到该列的最後一个字母
0 光标所在位置到该列的第一个字母
) 光标所在位置到下个句子的第一个字母
( 光标所在位置到该句子的第一个字母
} 光标所在位置到该段落的最後一个字母
{ 光标所在位置到该段落的第一个字母
说实在的,组合这些指令来编辑文件有一点点艺术气息。不管怎麽样,它们提供更多编辑文字的能力。值得注意的一点是删除与复制都会将指定范围的内容放到暂存区里,然後就可以用指令 p 贴到其它地方去,这是 vi 用来处理区段拷贝与搬移的办法。
某些 vi 版本,例如 Linux 所用的 elvis 可以大幅简化这一坨指令。如果稍微观察一下这些编辑指令就会发现问题其实是定范围的方式有点杂,实际上只有四个指令罢了。指令 v 非常好用,只要按下 v 键,光标所在的位置就会反白,然後就可以移动光标来设定范围,接著再直接下指令进行编辑即可。对於整列操作, vi 另外提供了更方便的编辑指令。前面曾经提到过删除整列文字的指令 dd 就是其中一个;cc 可以修改整列文字;而 yy 则是复制整列文字;指令 D 则可以删除光标到该列结束为止所有的文字。
(四)、文件操作指令
文件操作指令多以 : 开头,这跟编辑指令有点区别。
:q 结束编辑(quit)
:q! 不存档而要放弃编辑过的文件。
:w 保存文件(write)其後可加所要存档的档名。
:wq 即存档後离开。
zz 功能与 :wq 相同。
:x 与:wq相同

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






========cygwin=================

发帖时间: 05-05-08, 23:53

谢谢,楼上指点。
1楼说的那个没有看到
2楼的方法试过了。最快的是ftp://ftp.cise.ufl.edu
当然我不是全部试过,不过ping了20个肯定不只。这个最快只有200多ms的延时。我是电信的。
大家以后可以试试。
度我也试过了爽,我2M带宽下载速度达到100K接近。^_^~!!!!大家试试吧。
~~~~5分钟后,我又来了。装好了。^_^
这里的热情让我激动不已。




uname -a returns following output:
CYGWIN_NT-5.0 PCS734 1.3.5(0.47/3/2) 2001-11-13 23:16 i686 unknown
--install the ns under cygwin must under bash;


Please put /home/ns2/ns-allinone-2.28/bin:/home/ns2/ns-allinone-2.28/tcl8.4.5/unix:/home/ns2/ns-allinone-2.28/tk8.4.5/unix into your PATH; so that u will be able to run itm/tclsh/wish/xgraph.

important notices:

1. must put /home/ns2/ns-allinone-2.28/otcl-1.9, /home/ns2/ns-allinone-2.28/lib into your LD_LIBRARY_PATH variable;if it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH.
using csh, can set it like: setenv LD_LIBRARY_PATH
using sh, set like this: export LD_LIBRARY_PATH=

2. must put /home/ns2/ns-allinone-2.28/tcl8.4.5/library into ur TCL_LIBRARY env variable. otherwise, ns/nam will complain during startup

3. optional, to save disk space, u can delete directories tcl8.4.5 and tk8.4.5 installed under /home/ns2/ns-allinone-2.28/{bin,include,lib}

after this u can run ns validation suite with cd ns-2.28; ./validate


---set path for ns2----------------------
PATH="$PATH:/home/qyang/ns-allinone-2.28/bin:/home/qyang/ns-allinone-2.28/tcl8.4
.5/unix:/home/qyang/ns-allinone-2.28/tk8.4.5/unix"

#set env LD_LIBRARY_PATH /home/ns2/ns-allinone-2.28/otcl-1.9 wrong
#set env /home/ns2/ns-allinone-2.28/lib wrong
#no command setenv
#set LD_LIBRARY_PATH=/home/qyang/ns-allinone-2.28/otcl-1.9 wrong
#set env LD_LIBRARY_PATH /home/qyang/ns-allinone-2.28/lib wrong

#export LD_LIBRARY_PATH=/home/qyang/ns-allinone-2.28/otcl-1.9
#export LD_LIBRARY_PATH=/home/qyang/ns-allinone-2.28/lib
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/qyang/ns-allinone-2.28/otcl-1.9:/home/qy
ang/ns-allinone-2.28/lib"










u user
g group
o other
a all
r read
w write (and delete)
x execute (and access directory)
+ add permission
- take away permission
% chmod go-rwx biglist
% chmod a+rw biglist

cp file1 file2 copy file1 and call it file2
mv file1 file2 move or rename file1 to file2
rm file remove a file
rmdir directory remove a directory
cat file display a file
more file display a file a page at a time
head file display the first few lines of a file
tail file display the last few lines of a file
grep 'keyword' file search a file for keywords
wc file count number of lines/words/characters in file

还可以通过使用- R选项连同子目录下的文件一起设置:
chmod -R 664 /usr/local/home/dave/*

有相当一些U N I X命令也设置了s u i d和g u i d。如果想找出这些命令,可以进入/ b i n或/ s b i n目
录,执行下面的命令:
$ ls -l | grep '^...s'
上面的命令是用来查找s u i d文件的;
$ ls -l | grep '^...s..s'

u m a s k命令来改变文件创建的缺省权限

软链接实际上就是一个指向文件的指针。你将会发现这种软链接使用起来非常方便。你可以在每一位用户的$ H O M E目录下建立一个指向该文件的链接,而不是在每个目录下拷贝一份。这样当需要更改这一文
件时,只需改变一个源文件即可

$ find . -perm 755 -print
$ find ~ -user dave -print

$ find . -newer age.awk ! -newer belts.awk -exec ls -l {} \;

$touch -t 05042140 dstamp

在当前的文件系统中查找文件(不进入其他文件系统),可以使用f i n d命令的m o u n t选项
$ find . -name "*.XC" -mount -print



% echo $history
% set | less
.cshrc or .login
% nedit ~/.cshrc
% source .cshrc
% set path = ($path ~/units174/bin) //add to variable path
% cd; units //HINT: You can run multiple commands on one line by separating them with a semicolon.



$0$1$2$3$$$?$# --014.pdf-p143 shell编程和unix命令

使用u n s e t命令清除环境变量:

















Section===============新手入门循序渐进学习LINUX之软件配置=======================


LINUX配置

  在这里,配置的对象并非内核,而是软件。至于网络的配置,主要在安装系统是已经基本完成;也可以进入GUI界面从菜单选择liloconf来配置。


  与WINDOWS一样,在LINUX系统可以从光盘、软盘安装应用软件;但不同的是,它需要用命令mount来登录光驱、软驱。而且,软件大多是经过压缩的,所以还需要懂得如何解压。最后必须配置、编译才能运行。下面分四个方面进行介绍:


  一、mount登录

  LINUX的软驱设备用特殊文件/dev/fd0,文件系统是msdos,因此用以下命令登录,读取软盘内容:

  # mount -t msdos /dev/fd0 /mnt/floppy
  # cd /mnt/floppy
  同理,键入以下命令读光盘:
  # mount -t iso9660 /dev/hdb /mnt/cdrom
  # cd /mnt/cdrom
  然后,用cp命令将所需的软件拷贝到系统中。
  退出软驱、光驱用umount命令。注意,不能在其目录中使用此命令,而应先cd到其他目录,再使用:umount /mnt/cdrom。

  
  二、安装软件

  for
LINUX的软件一般是以.gz或.tar或者.tar.gz结尾的。前者是由gzip压缩的,后者是先用tar归档,在用gzip压缩而成的。


  1、以.gz结尾的为压缩文件,用命令:gzip -d filename来解压,得到的文件在当前目录中,但已没有了.gz。

  2、以.tar结尾的为归档文件,用命令:tar -xvf filename来展开,生成的文件与源文件在同一目录中,只是少了.tar。


  3、以.tar.gz结尾的文件最常见,可直接用命令:gzip -cd filename | tar xfv -来安装。

  一般情况下,这类文件的第一项是一个目录,所以用上面的命令时会创建出这一个目录,并把所有的文件都存在此目录之下。如果是特殊情况,可先用命令:tar
-tvf filename | more 来查看文件的第一项。倘若它并不是目录,则先创建一个目录,把文件放在此目录之下,在用命令:tar
-xvf filename来安装。

  经过以上步骤,会生成README及INSTALL等文件。用vi来仔细阅读这些文件造处于LINUX有关的部分,更具体是进行配置。一般的步骤是:(1)./config,(2)make
install,(3)make。主要的变化在第一步,其后面需要参数,可见入命令来选择:./config --help。
  
  三、实践举例笔者曾配置了apache(阿帕其服务器)、php3两个软件。

  先从网上下载for LINUX的软件apache.tar.gz、php3.tar.gz。

  1、由于apache.tar.gz大于1.44M,所以笔者在center_5的MSDOS上用telnet命令登录LINUX,通过put将其上传。


  2、笔者将这两个软件放在/usr/src目录之下,用命令gzip -cd apache.tar.gz(php3.tar.gz)|
tar xfv -来安装。这样会看到两个目录:apache_1.3.6和php-3.0.7。

  3、在第一个目录之下,会看到非常重要的文件:README、INSTALL。如果此时是在GUI界面,则可以打开两个xterm,一个用于仔细阅读,一个则用于根据文件的提示进行配置。


  4、在第二个目录中,也会很快的找到文件:INSTALL、INSTALL.DSO、README.QNX。步骤与3相似。由于这两个文件相互关联,必须先配置前者。


  5、配置完后,进入/apache_1.3.6/conf/httpd.conf。在文件里面,理解其注释,删除或增加一些选项前的"#"。保存文件后,执行命令/usr/src/apache_1.3.6/bin/apachectl
start,即打开http,然后可以在Netscape Communication来浏览网页。

  心得体会在学习的一个多月来,笔者面对的是一个全新的操作系统,绝大多数操作是通过自己键入命令来实现的,从而能够深入到一定层次的了解操作系统内核。


  1、懂得了UNIX的一些基本命令;
  2、熟悉vi文本编辑;
  3、知道如何在LINUX、UNIX上编写、编译C、C++、JAVA程序;
  4、进一步了解了网络原理,动手配置了网络应用软件,从而也清楚了软件安装的一般步骤。
  5、毕竟现今for LINUX的应用软件少,而且RedHat
LINUX不支持中文,因而还不能完全脱离WINDOWS。因此,应发挥LINUX是一个非常优秀的网络服务器操作系统的优点,扬长避短。

  
=================from linuxsir bbs ==============
用dos的引导盘使用fdisk /mbr清除引导区信息!
然后用redhat的第一张光盘引导,进入linux rescue模式!
重新安装grub!

发帖时间: 05-03-31, 00:05
在GRUB中用单用户模式进去~~
然后vi /etc/shadow 找到ROOT把ROOT后一个MD5格式的字符串"干掉".保存~然后重启重新用单用户模式进入passwd root 自己输入需要的密码就好了~
--this can work by quentin, root:xxxxx:19333:....., just delete the xxx between colon. verified under red hat linux.

类似这样的,然后把键盘移动到该句,再按一下[e]键,在类似的语句后面加上 linux single。然后就按回车[enter]。然后出现另外一个界面,按一个[b]键。这样GRUB就把系统引入单用户模式了。
可能出现的是这样的。。。 just add linux single, can enter single mode, verified by quentin under red hat.


http://www.linuxsir.org/bbs/showthread.php?s=&threadid=16998 在GRUB系统引导程序下进入单用户模式的办法

http://www.linuxsir.org/bbs/showthread.php?s=&threadid=8721
http://www.linuxsir.org/bbs/showthread.php?s=&threadid=3393
发帖时间: 02-07-28, 00:48
让系统自动加载FAT32

用下面这个命令来判断我们的windows分区,这个命令能把所有硬盘上的分区都能列出来。这个命令比较强,哈。。最适合不知道自己的硬盘情况的弟兄。。。


[root@LinuxSir root]# fdisk -l

如果只列一个硬盘的可用下面这个命令,下面这两条命令,第一条是列第一个硬盘的,第二个是列第二个硬盘的,这两条命令和 fdisk -l结合起来,配合来用,效果最佳。我以我的硬盘来说。。。。也能用第一个命令。。这个比较简单,试一下就知道了
#fdisk -l /dev/hda
#fdisk -l /dev/hdb



Disk /dev/hda: 255 heads, 63 sectors, 4865 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1147 9213246 7 HPFS/NTFS
/dev/hda2 1148 4864 29856802+ f Win95 Ext'd (LBA)
/dev/hda5 1148 2039 7164958+ 7 HPFS/NTFS
/dev/hda6 2040 2804 6144831 b Win95 FAT32
/dev/hda7 2805 3824 8193118+ b Win95 FAT32
/dev/hda8 3825 3830 48163+ 83 Linux
/dev/hda9 3831 4799 7783461 83 Linux
/dev/hda10 4800 4864 522081 82 Linux swap

从这上面,我们可以看来,/dev/hda6和/dev/hda7就是win下的fat32分区。

第二;我们加载windows的分区,是不是在linux下有个文件夹可以放下去?这样理解就对了。我们可以用下面的方法来操作。我在这个例子中,把/hda6的内容,我想放到WinE这个文件夹。另一个则是WinF,这个文件夹的命名,可以用你喜欢的。但修改/etc/fstab的内容时,也要用这个文件夹,也就是统一起来。。
#mkdir /mnt/WinE
#mkdir /mnt/WinF

注意大小写。。

或用鼠标点kde自带的浏览器在地址栏上输入:
/mnt
就能进入/mnt这个目录了。。
然后就按鼠标的右键来建目录,这个简单吧。。。哈。。

然后,我们来修改/etc目录下的fstab

/dev/hda6 /mnt/WinE vfat rw,codepage=936,iocharset=cp936 0 0
如果加E盘就是:
/dev/hda7 /mnt/WinF vfat rw,codepage=936,iocharset=cp936 0 0
然后在/mnt/下建立目录WinD和WinE
对于Redhat 8.0,应该把codepage=936去掉
然后在KDE桌面上用右键点击[新建]-》硬 盘-》然后就点几下鼠标就OK了。。。


如果手工mount分区如何做呢?
事前要建好目录,比如在/mnt目录下建一个tmp目录
#mkdir /mnt/tmp
然后就是mount了,mount也应该有个目的地吧,那我们就把目的地定为/mnt/tmp
比如我们mount /dev/hda1
如下:
#mount -o iocharset=cp936 /dev/hda1 /mnt/tmp


北南老大,我只在/etc/fstab中添加,另一个文件etc/mtab好像已经自动添加了.
是不是RH73有这个功能的?
哈哈。。兄弟,这个mtab是系统关机时umount时要用到的。。。

在mnt目录下建立你想要的分区名称如WinD,然后用下面的指令格式加载.
当然你可以在etc中修改fstab文件.这样可以自动加载
/dev/hda9 /mnt/F vfat default,codepage=936,iocharset=gb2312 0 0
******************************************************
我的fstab文件格式,参考一下
/dev/hda1 /mnt/C vfat default,codepage=936,iocharset=gb2312 0 0
/dev/hda7 /mnt/D vfat default,codepage=936,iocharset=gb2312 0 0
/dev/hda8 /mnt/E vfat default,codepage=936,iocharset=gb2312 0 0
/dev/hda9 /mnt/F vfat default,codepage=936,iocharset=gb2312 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu,codepage=936,iocharset=gb2312 0 0
这样可以显示中文的.你试一下

[root@localhost root]# fdisk -l

Disk /dev/hdc: 255 heads, 63 sectors, 4865 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 1217 9775521 c Win95 FAT32 (LBA)
/dev/hdc2 1218 4865 29302560 f Win95 Ext'd (LBA)
/dev/hdc5 1218 3046 14691411 b Win95 FAT32
/dev/hdc6 3047 3569 4200966 b Win95 FAT32
/dev/hdc7 3570 4092 4200966 b Win95 FAT32
/dev/hdc8 4093 4829 5919921 83 Linux
/dev/hdc9 4830 4865 289138+ 82 Linux swap
[root@localhost root]#
就是这个样子的 你帮我看看吧

mount -t vfat /dev/hdc5 /mnt/winD






Section==============Web Resources==============================
CN-------------www.linuxeden.com
CN-------------www.linuxforum.net
CN-------------www.linuxfans.org
CN-------------www.linuxsir.org/bbs
CN-------------http://bbs.chinaunix.net/viewthread.php?tid=746147
CN-------------http://fedora.linuxsir.org/main/?q=aggregator/sources/1
CN-------------http://linux.chinaunix.net/
CN-------------http://slack.linuxsir.org/main/?q=node/145

CN-------------http://www.math.zju.edu.cn/ligangliu/LaTeXForum/tex_edit.htm
CN-------------ftp://ftp.ctex.org/pub/tex/systems/ctex/ --download CTeX package
EN-------------ctan.tug.org/starter.html ---the comprehensive ReX Archive Network
EN-------------www.winedt.com ---winedit download
EN-------------www.tug.org/begin.html
EN-------------www.gnu.org/software/emacs/manual/---GNU Emacs Manual
EN---------http://rpmfind.net/linux/RPM 去这里找一下这几个包吧!
EN------http://grub4dos.sourceforge.net/ http://sourceforge.net/projects/grub4dos


EN-------------http://www.slackworld.net/01/tips.html


EN-------------http://gurus.com.au/JobSeeker/Default.aspx ----IT career



EN-----java--------http://forum.java.sun.com/thread.jspa?threadID=568603&messageID=2810271
EN-----java--------http://java.sun.com/j2se/1.4.2/docs/api/overview-summary.html
CN-----.Net--------http://www.chinaaspx.com/archive/Java/20906.htm China .net club/ is used for search a certain word, C-s is used for searching as well when reading info help ? to get command list for reading info

#uname //list system information, like kernel version.





#df -a -h


man: list hard disk space usage under linux.







# chown -R q.yang repos_personal/


man: change access right




#chgrp admin -R /opt/mysql/var/


man: change group


# chmod 771 -R /opt/mysql/var

man: change access right

Monday, November 24, 2008

ICSP pinouts

From:

http://www.embedinc.com/picprg/icsp.htm

ICSP Overview

In-circuit Serial Programming (ICSP)


PICs are programmed using 5 signals. The data is transferred using a two wire synchronous serial scheme, with the clock always controlled by the programmer. The ICSP signals are:

GND

Negative power input to the PIC and the ground reference for the remaining signals. Voltages of the other signals are implicitly with respect to GND unless otherwise specified.

Vdd

This is the positive power input to the PIC. Some programmers require this to be provided by the circuit (circuit must be at least partially powered up), some programmers expect to drive this line themselves and require the circuit to be off, while others can be configured either way (like the Microchip ICD2). The Embed Inc programmers expect to drive the Vdd line themselves and require the target circuit to be off during programming.

Vpp

Programming mode voltage. This must be connected to the MCLR pin of the target PIC. To put the PIC into programming mode, this line must be in a specified range that varies between PICs, but is always above Vdd. The highest maximum allowed Vpp voltage that we know of is 13.5 volts. There is no one Vpp voltage that is within the valid Vpp range of all PICs.

PGC

Clock line of the serial data interface. This line swings from GND to Vdd and is always driven by the programmer. Data is transferred on the falling edge.

PGD

Serial data line. The serial interface is bi-directional, so this line can be driven by either the programmer or the PIC depending on the current operation. In either case this line swings from GND to Vdd. A bit is transferred on the falling edge of PGC.

Thursday, November 20, 2008

在C++Builer中多线程的实现

From: http://www.ccrun.com/
在C++Builer中多线程的实现
关键字:多线程,多任务,TThread对象
作者:Yinyin 更新:2002-11-15 浏览:8045

还在Dos时代,人们就在寻求一种多任务的实现。于是出现了TSR类型的后台驻留程序,比较有代表性的有Side Kick、Vsafe等优秀的TSR程序,这类程序的出现和应用确实给用户使用计算机带来了极大的方便,比如Side Kick,我们编程可以在不用进编辑程序的状态下,一边编辑源程序,一边编译运行,非常方便。但是,Dos单任务操作系统的致命缺陷注定了在Dos下不可能开发出真正的多任务程序。进入Windows3.1时代,这种情况依然没有根本的改变,一次应用只能做一件事。比如数据库查询,除非应用编得很好,在查询期间整个系统将不响应用户的输入。
  进入了Windows NT和Windows 9x时代,情况就有了彻底的改观,操作系统从真正意义上实现了多任务(严格地说,Win9x还算不上)。一个应用程序,在需要的时候可以有许多个执行线程,每个线程就是一个小的执行程序,操作系统自动使各个线程共享CPU资源,确保任一线程都不能使系统死锁。这样,在编程的时候,可以把费时间的任务移到后台,在前台用另一个线程接受用户的输入。对那些对实时性要求比较高的编程任务,如网络客户服务、串行通信等应用时,多线程的实现无疑大大地增强了程序的可用性和稳固性。
  在Windows NT和Windows 9x中,多线程的编程实现需要调用一系列的API函数,如CreateThread、ResumeThread等,比较麻烦而且容易出错。我们使用 Inprise公司的新一代RAD开发工具C++Builder,可以方便地实现多线程的编程。与老牌RAD工具Visual Basic和Delphi比,C++Builer不仅功能非常强大,而且它的编程语言是C++,对于系统开发语言是C的Windows系列操作系统,它具有其它编程语言无可比拟的优势。利用C++Builder提供的Tthread对象,多线程的编程变得非常简便易用。那么,如何实现呢?且待我慢慢道来,让你体会一下多线程的强大功能。
  1. 创建多线程程序:
  首先,先介绍一下实现多线程的具体步骤。在C++Builder中虽然用Tthread对象说明了线程的概念,但是Tthread对象本身并不完整,需要在Tthread下新建其子类,并重载Execute方法来使用线程对象。在C++Builder下可以很方便地实现这一点。
  在C++Builder IDE环境下选择菜单File|New,在New栏中选中Thread Object,按OK,接下来弹出输入框,输入Tthread对象子类的名字MyThread,这样C++Builder自动为你创建了一个名为 TMyThread的Tthread子类。同时编辑器中多了一个名为Unit2.cpp的单元,这就是我们创建的TMyThread子类的原码,如下:
  #include
  #pragma hdrstop
  
  #include “Unit2.h”
  #pragma package(smart_init)
  //---------------------
  // Important: Methods and properties of objects in VCL can only be
  // used in a method called using Synchronize, for example:
  //
  // Synchronize(UpdateCaption);
  //
  // where UpdateCaption could look like:
  //
  // void __fastcall MyThread::UpdateCaption()
  // {
  // Form1->Caption = “Updated in a thread”;
  // }
  //--------------------
  __fastcall MyThread::MyThread(bool CreateSuspended)
   : Tthread(CreateSuspended)
  {
  }
  //--------------------
  void __fastcall MyThread::Execute()
  {
   //---- Place thread code here ----
  }
  //---------------------
  其中的Execute()函数就是我们要在线程中实现的任务的代码所在处。在原代码中包含Unit2.cpp,这个由我们创建的TMyThread对象就可以使用了。使用时,动态创建一个TMyThread 对象,在构造函数中使用Resume()方法,那么程序中就增加了一个新的我们自己定义的线程TMyThread,具体执行的代码就是Execute()方法重载的代码。要加载更多的线程,没关系,只要继续创建需要数量的TMyThread 对象就成。
  以上我们初步地实现了在程序中创建一个自定义的线程,并使程序实现了多线程应用。但是,多线程应用的实现,并不是一件简单的工作,还需要考虑很多使多个线程能在系统中共存、互不影响的因素。比如,程序中公共变量的访问、资源的分配,如果处理不当,不仅线程会死锁陷入混乱,甚至可能会造成系统崩溃。总的来讲,在多线程编程中要注意共享对象和数据的处理,不能忽视。因此,下面我们要讲的就是多线程中常见问题:
  2. 多线程中VCL对象的使用
  我们都知道,C++Builder编程是建立在VCL类库的基础上的。在程序中经常需要访问VCL对象的属性和方法。不幸的是,VCL类库并不保证其中对象的属性和方法是线程访问安全的(Thread_safe),访问VCL对象的属性或调用其方法可能会访问到不被别的线程所保护的内存区域而产生错误。因此,Tthread对象提供了一个Synchronize方法,当需要在线程中访问VCL对象属性或调用方法时,通过Synchronize方法来访问属性或调用方法就能避免冲突,使各个线程之间协调而不会产生意外的错误。如下所示:
// 本文转自 C++Builder研究 - http://www.ccrun.com/article.asp?i=260&d=638igb
  void __fastcall TMyThread::PushTheButton(void)
  
  {
   Button1->Click();
  }
  
  void __fastcall TMyThread::Execute()
  {
   …
   Synchronize((TThreadMethod)PushTheButton);
   …
  }
  对Button1-〉Click()方法的调用就是通过Synchronize()方法来实现的,它可以自动避免发生多线程访问冲突。在C++ Builder中,虽然有一些VCL对象也是线程访问安全的(如Tfont、Tpen、Tbrush等),可以不用Sychronize()方法对它们的属性方法进行访问调用以提高程序性能,但是,对于更多的无法确定的VCL对象,还是强烈建议使用Synchronize()方法确保程序的可靠性。
  3. 多线程中公共数据的使用
  程序设计中难免要在多个线程中共享数据或者对象。为了避免在多线程中因为同时访问了公共数据块而造成灾难性的后果,我们需要对公共数据块进行保护,直到一个线程对它的访问结束为止。这可以通过临界区域(Critical Section)的使用来实现,所幸的是在C++Builder中,给我们提供了一个TCriticalSection对象来进行临界区域的划定。该对象有两个方法,Acquire()和Release()。它设定的临界区域可以保证一次只有一个线程对该区域进行访问。如下例所示:
  class MyThread : public Tthread
  {
   …
  private:
  TCriticalSection pLockX;
  int x;
  float y;
  …
  };
  void __fastcall MyThread::Execute()
  {
  …
  pLockX->Acquire();//Here pLockX is a Global CriticalSection variable.
  x++;
  y=sin(x);
  pLockX->Release();
  …
  }
  这样,对公共变量x,y的访问就通过全局TCriticalSection 对象保护起来,避免了多个线程同时访问的冲突。
  4. 多线程间的同步
  当程序中多个线程同时运行,难免要遇到使用同一系统资源,或者一个线程的运行要依赖另一个线程的完成等等,这样需要在线程间进行同步的问题。由于线程同时运行,无法从程序本身来决定运行的先后快慢,使得线程的同步看起来很难实现。所幸的是Windows系统是多任务操作系统,系统内核为我们提供了事件(Event)、Mutex、信号灯(semaphore)和计时器4种对象来控制线程间的同步。在C++Builder中,为我们提供了用于创建 Event的Tevent 对象供我们使用。
  当程序中一个线程的运行要等待一项特定的操作的完成而不是等待一个特定的线程完成时,我们就可以很方便地用Tevent对象来实现这个目标。首先创建一个全局的Tevent对象作为所有线程可监测的标志。当一个线程完成某项特定的操作时,调用Tevent对象的SetEvent()方法,这样将设置这个标志,其他的线程可以通过监测这个标志获知操作的完成。相反,要取消这个标志,可以调用ResetEvent()方法。在需要等待操作完成的线程中使用 WaitFor()方法,将一直等待这个标志被设置为止。注意WaitFor()方法的参数是等待标志设置的时间,一般用INFINITE表示无限等待事件的发生,如果其它线程运行有误,很容易使这个线程死住(等待一个永不发生的事件)。
  其实直接用Windows API函数也可以很方便地实现事件(Event)、信号灯(semaphore)控制技术。尤其是C++Builder,在调用Windows API方面有着其它语言无可比拟的优势。所用的函数主要有:CreateSemaphore()、CreateEvent()、 WaitForSingleObject()、ReleaseSemaphore()、SetEvent()等等,这里就不赘述了。
  本文结合Inprise(Borland)公司开发的强大的RAD工具C++Builder的编程,对Windows下的多线程编程作了比较全面的介绍。其实多线程的实现并不神秘,看了本文,你也可以编出自己的多线程程序,真正体会多任务操作系统的威力。
  附:本文是本人在使用C++Builder一年来的一些实践体会。在完成自己的项目的同时,发现对多线程的编程一般的书籍都介绍得比较少,而实际应用中,多线程编程又是如此的重要,因此,本文通过对多线程编程比较全面的介绍,愿能达到抛砖引玉之效。

C++Builder的多线程编程中一些体会
关键字:多线程编程,TThread
作者:佚名 更新:2002-12-26 浏览:11041

最近在写一个程序用到了多线程,所以对CB下的多线程有一定的学习。
现在把自己的一些心得讲一下。水平有限,写的很粗略,请大家见谅。

CB相对于VC来说,在CB下写多线程程序是很简单的。不仅是VCL中有TThread这个类。封装了那些关于多线程的WINDOW API。我觉得更方便的是他提供了
直接访问主VCL线程中对象的能力。可以很容易的和主线程中的窗体,控件
打交道。和单线程的方式没有太多区别。只是在有多个线程都要访问主线程
中的对象(比如访问同一个窗体上的StringGrid).只要用Thread的Synchronize方法来调用那段访问主VCL线程的代码(具体请看帮助),我们就不用担心访问冲突的问题了。而且对于多线程的同步和互斥,CB也对WINDOW 编程中那些机制进行了封装。比如对临界区CriticalSection封装为TCriticalSection.事件Event封装为TEvent.这些类相当简单好用。
下面就是我觉得比较重要的几点,供大家参考.


1。TThread的WaitFor方法。是等待一个线程返回。其返回值在这个线程里可以任意设定。以便在该线程返回的时候让调用他的线程知道他的运行情况。

在TThread的 OnTerminate事件中做线程的清除工作。他不是线程运行的一部分。
而是主VCL线程的一部分。所以在其中不能访问Thread的局部变量(如 int __thread i)
你可以把清楚代码写在这里,不用管现在在EXCUTE()方法执行到了哪个地方。
这么看起来有点类似于C++里的 finally 块的作用。

2。TEvent很重要。实现线程的同步。WaitFor(int Timeout)功能类似于
WINDOW API WaitforSingleObject().返回值包括:
其中参数Timeout可以设为INFINITE表示永久等待,但这样,程序很容易死在这里。

wrSignaled 该事件发生(成功返回).
本文转自 C++Builder研究 - http://www.ccrun.com/article.asp?i=393&d=82l8wk
wrTimeout 等待超时.
wrAbandoned 在该事件的超时期限到达前,该事件对象已经被毁灭了。.
wrError 在等待过程中有异常产生,要知道具体产生的错误要查看 TEvent的LastError
属性。

3 TCriticalSection
这个相当于WIN32编程中的临界区。
在多线程编程中,多个线程需要访问同一个公用变量的时候。

来保证访问的正确性。对公用变量访问的代码写在Enter();和Leave()之间。
比如有个公用变量 Count;
以下代码 :
TCriticalSection * pSection=new TCriticalSection();
pSection->Enter();
Count++;
pSection->Leave();
delete p;

Enter()方法进入临界区,对其中的公用变量加锁。
Leave()方法离开临界区,对其中的公用变量解锁。


4.TMultiReadExclusiveWriteSynchronizer
用来处理类似于多个生产者和多个消费者的问题。这里的消费者是指
对公用变量进行读操作的线程。
生产者是对公用变量进行写操作的线程。

四个方法。
BeginRead
EndRead
这两个方法用于消费者。
BeginWrite
EndWrite
这两个方法用于生产者。

使用的时候就是要把这个TMutiReadExclusiveWriteSynchronizer 定义一个全局变量。然后在其他线程中访问他。

Php First Example - hello world.

PHP only parses code within its delimiters. Anything outside its delimiters is sent directly to the output and is not parsed by PHP. The most common delimiters are and ?>, which are open and close delimiters respectively. delimiters are also available. Short tags ( or and ?>) are also commonly used, but like ASP-style tags (<% or <%= and %>), they are less portable as they can be disabled in the PHP configuration. For this reason, the use of short tags and ASP-style tags is discouraged.[50] The purpose of these delimiters is to separate PHP code from non-PHP code, including HTML. Everything outside the delimiters is ignored by the parser and is passed through as output.



PHP Test


Hello World

' ?>

Word Tips--上标

首先选中需要做上标文字,然后按下组合键Ctrl+Shift+=就可将文字设为上标,再按一次又恢复到原始状态;按Ctrl+=可以将文字设为下标,再按一次也恢复到原始状态

insert check box in word 2003

1. Insert Table.
2. View --> ToolBar --> forms

winxp-file-Share

方法一:解除对Guest账号的限制
  点击“开始→运行”,在“运行”对话框中输入“GPEDIT.MSC”,打开组策略编辑器,依次选择“计算机配置→Windows设置→安全设置→本地策略→用户权利指派”,双击“拒绝从网络访问这台计算机”策略,删除里面的“GUEST”账号。这样其他用户就能够用Guest账号通过网络访问使用 Windows XP系统的计算机了。
方法二:更改网络访问模式
  打开组策略编辑器,依次选择“计算机配置→Windows设置→安全设置→本地策略→安全选项”,双击“网络访问:本地账号的共享和安全模式”策略,将默认设置“仅来宾—本地用户以来宾身份验证”,更改为“经典:本地用户以自己的身份验证”。
  现在,当其他用户通过网络访问使用Windows XP的计算机时,就可以用自己的“身份”进行登录了(前提是Windows XP中已有这个账号并且口令是正确的)。
  当该策略改变后,文件的共享方式也有所变化,在启用“经典:本地用户以自己的身份验证”方式后,我们可以对同时访问共享文件的用户数量进行限制,并能针对不同用户设置不同的访问权限。
  不过我们可能还会遇到另外一个问题,当用户的口令为空时,访问还是会被拒绝。原来在“安全选项”中有一个“账户:使用空白密码的本地账户只允许进行控制台登录”策略默认是启用的,根据Windows XP安全策略中拒绝优先的原则,密码为空的用户通过网络访问使用Windows XP的计算机时便会被禁止。我们只要将这个策略停用即可解决问题。  五、如何共享访问 Windows XP 中的加密文件
一、网络协议的安装和设置
  1.在WinXP中安装NetBEUI协议
  对的,你没有看错,就是要在WinXP中安装NetBEUI协议。微软在WinXP中只支持TCP/IP协议和NWLink IPX/SPX/NetBIOS兼容协议,正式宣布不再支持NetBEUI协议。但是在建立小型局域网的实际使用中,使用微软支持的两种协议并不尽如人意。比如,在解决网上邻居慢问题的过程中,笔者采用了诸多方法后网上邻居的速度虽然好一点,但还是慢如蜗牛;另外,在设置多块网卡的协议、客户和服务绑定时,这两种协议还存在BUG,多块网卡必须同时绑定所有的协议(除NWLink NetBIOS)、客户和服务,即使你取消某些绑定重启后系统又会自动加上,这显然不能很好地满足网络建设中的实际需要。而当笔者在WinXP中安装好 NetBEUI协议后,以上两个问题都得到圆满的解决。
  在WinXP安装光盘的“\valueADD\MSFT\NET\NETBEUI”目录下有3个文件,其中“NETBEUI.TXT”是安装说明,另外两个是安装NetBEUI协议所需的文件。安装的具体步骤如下:
  复制“NBF.SYS”到“%SYSTEMROOT%\SYSTEM32\DRIVERS\”目录;
  复制“NETNBF.INF”到“%SYSTEMROOT%\INF\”目录;
  在网络连接属性中单击“安装”按钮来安装NetBEUI协议。
  注:%SYSTEMROOT%是WinXP的安装目录,比如笔者的WinXP安装在F:\Windows目录下,就应该用F:\Windows来替换%SYSTEMROOT%。
  2.在WinXP中设置好其它网络协议
  笔者建议,如果你的局域网不用上Internet便只需要安装NetBEUI协议就行了。在小型局域网(拥有200台左右电脑的网络)中NetBEUI是占用内存最少、速度最快的一种协议,NWLink IPX/SPX/NetBIOS兼容协议则应当删除掉。
  如果你的局域网要上Internet则必须安装TCP/IP协议。但为了网络的快速访问,建议指定每台工作站的IP地址(除非网络中有DHCP服务器),否则工作站总是不断查找DHCP服务器使网速变慢。
  当然,如果网络中只安装TCP/IP协议也能够实现局域网中的互访,但是在网上邻居中要直接看到其它机器就比较困难,必须先搜索到某台机器后才能访问它,这在许多实际网络运用中显得很不方便。

UART-Access-in-Windowns (General)

To use the serial port in Win32 you can use the CreateFile (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp) function to setup a handle to the hardware. Specify the port name in place of the file name (e.g. "COM1"). Then you need to use the DCB (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/dcb_str.asp) struct. The DCB struct has members for setting up the baud rate, flow control, parity....etc. Set all of the parameters you want in the DCB struct, or have dialogs that let the user select the ones they want, and then use the SetCommState (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/setcommstate.asp) function to configure the port with the parameters in the DCb struct. You will also need to set the timeouts for the port with the SetCommTimeouts (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/setcommtimeouts.asp). Also you'll need to set buffer sizes with the SetupComm (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/setupcomm.asp) function.

Once the port is opened (briefly outlined above) use the ReadFile and WriteFile functions to read and write from and to the port. To switch individual lines on the port (RTS, DTR..etc) use EscapeCommFunction (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/escapecommfunction.asp).

That is just a quick overview but the links provided should get you started.

TDM

Remote Desktop in Winxp -- Hints

Two things to be done:
1. Enable Remote Desktop in Network Firewall settings.
2. Enable remote access in Control Panel --> System --->Remote

View Linux Drive from Windows - SAMBA - Fedora 5


[q.yang@glomesprod01 ~]$ ls -alt /etc/samba/smb.conf
-rw-r--r-- 1 root root 10704 Feb 14 2006 /etc/samba/smb.conf
[q.yang@glomesprod01 ~]$ yum install system-config-samba
Loading "installonlyn" plugin
You need to be root to perform this command.
[q.yang@glomesprod01 ~]$ su
Password:
[root@glomesprod01 q.yang]# yum install system-config-samba
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
core 100% |=========================| 1.1 kB 00:00
updates [2/3]
updates 100% |=========================| 1.2 kB 00:00
extras [3/3]
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 767 kB 00:01
core : ################################################## 2207/2207
Added 2207 new packages, deleted 0 old in 43.32 seconds
primary.xml.gz 100% |=========================| 362 kB 00:09
updates : ################################################## 1013/1013
Added 1013 new packages, deleted 0 old in 20.89 seconds
primary.xml.gz 100% |=========================| 1.3 MB 00:09
extras : ################################################## 4277/4277
Added 4277 new packages, deleted 0 old in 73.21 seconds
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for system-config-samba to pack into transaction set.
system-config-samba-1.2.3 100% |=========================| 32 kB 00:00
---> Package system-config-samba.noarch 0:1.2.34-1 set to be updated
--> Running transaction check
--> Processing Dependency: samba for package: system-config-samba
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for samba to pack into transaction set.
samba-3.0.24-7.fc5.i386.r 100% |=========================| 109 kB 00:02
---> Package samba.i386 0:3.0.24-7.fc5 set to be updated
--> Running transaction check
--> Processing Dependency: cups-libs >= 1:1.2.8-1 for package: samba
--> Processing Dependency: samba-common = 0:3.0.24-7.fc5 for package: samba
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for cups-libs to pack into transaction set.
cups-libs-1.2.8-1.fc5.i38 100% |=========================| 35 kB 00:00
---> Package cups-libs.i386 1:1.2.8-1.fc5 set to be updated
---> Downloading header for samba-common to pack into transaction set.
samba-common-3.0.24-7.fc5 100% |=========================| 42 kB 00:01
---> Package samba-common.i386 0:3.0.24-7.fc5 set to be updated
--> Running transaction check
--> Processing Dependency: cups-libs = 1:1.1.23 for package: cups
--> Processing Dependency: samba-common = 0:3.0.21b-2 for package: samba-client
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for cups to pack into transaction set.
cups-1.2.8-1.fc5.i386.rpm 100% |=========================| 199 kB 00:05
---> Package cups.i386 1:1.2.8-1.fc5 set to be updated
---> Downloading header for samba-client to pack into transaction set.
samba-client-3.0.24-7.fc5 100% |=========================| 38 kB 00:01
---> Package samba-client.i386 0:3.0.24-7.fc5 set to be updated
--> Running transaction check
--> Processing Conflict: cups conflicts foomatic < 3.0.2-33.3
--> Processing Conflict: cups conflicts system-config-printer < 0.6.151.3
--> Processing Conflict: cups conflicts hplip < 0.9.9-5.1
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for foomatic to pack into transaction set.
foomatic-3.0.2-33.3.i386. 100% |=========================| 536 kB 00:10
---> Package foomatic.i386 0:3.0.2-33.3 set to be updated
---> Downloading header for hplip to pack into transaction set.
hplip-1.6.6a-1.1.i386.rpm 100% |=========================| 96 kB 00:01
---> Package hplip.i386 0:1.6.6a-1.1 set to be updated
---> Downloading header for system-config-printer to pack into transaction set.
system-config-printer-0.6 100% |=========================| 70 kB 00:01
---> Package system-config-printer.i386 0:0.6.151.8-1 set to be updated
--> Running transaction check
--> Processing Dependency: hpijs = 1:1.6.6a-1.1 for package: hplip
--> Processing Dependency: system-config-printer = 0.6.151-1 for package: system-config-printer-gui
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for hpijs to pack into transaction set.
hpijs-1.6.6a-1.1.i386.rpm 100% |=========================| 7.8 kB 00:00
---> Package hpijs.i386 1:1.6.6a-1.1 set to be updated
---> Downloading header for system-config-printer-gui to pack into transaction set.
system-config-printer-gui 100% |=========================| 51 kB 00:01
---> Package system-config-printer-gui.i386 0:0.6.151.8-1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
system-config-samba noarch 1.2.34-1 core 246 k
Installing for dependencies:
samba i386 3.0.24-7.fc5 updates 16 M
Updating for dependencies:
cups i386 1:1.2.8-1.fc5 updates 2.9 M
cups-libs i386 1:1.2.8-1.fc5 updates 180 k
foomatic i386 3.0.2-33.3 updates 13 M
hpijs i386 1:1.6.6a-1.1 updates 221 k
hplip i386 1.6.6a-1.1 updates 7.8 M
samba-client i386 3.0.24-7.fc5 updates 4.2 M
samba-common i386 3.0.24-7.fc5 updates 8.5 M
system-config-printer i386 0.6.151.8-1 updates 1.1 M
system-config-printer-gui i386 0.6.151.8-1 updates 214 k

Transaction Summary
=============================================================================
Install 2 Package(s)
Update 9 Package(s)
Remove 0 Package(s)
Total download size: 54 M
Is this ok [y/N]:
ownloading Packages:
(1/11): cups-1.2.8-1.fc5. 100% |=========================| 2.9 MB 00:53
(2/11): foomatic-3.0.2-33 100% |=========================| 13 MB 03:46
(3/11): hpijs-1.6.6a-1.1. 100% |=========================| 221 kB 00:04
(4/11): samba-3.0.24-7.fc 100% |=========================| 16 MB 05:18
(5/11): samba-common-3.0. 100% |=========================| 8.5 MB 02:37
(6/11): cups-libs-1.2.8-1 100% |=========================| 180 kB 00:02
(7/11): samba-client-3.0. 100% |=========================| 4.2 MB 01:29
(8/11): system-config-pri 100% |=========================| 214 kB 00:05
(9/11): hplip-1.6.6a-1.1. 100% |=========================| 7.8 MB 02:26
(10/11): system-config-sa 100% |=========================| 246 kB 00:00
(11/11): system-config-pr 100% |=========================| 1.1 MB 00:35
[root@glomesprod01 q.yang]#

[q.yang@glomesprod01 ~]$ system-config-securitylevel
[q.yang@glomesprod01 ~]$ system-config-users
[q.yang@glomesprod01 ~]$ system-config-samba

Samba uses /etc/samba/smb.conf as its configuration file. If you change this configuration file, the changes will not take effect until you restart the Samba daemon with the command

#service smb restart.

A Samba user account will not be active until a Samba password is set for it.

#smbpasswd -a q.yang
New SMB password:
Retype new SMB password:



Relevant Link: http://www.reallylinux.com/docs/sambaserver.shtml


VNC set up in Fedora

[1] http://fedoranews.org/tchung/vnc/
[2] http://bobpeers.com/linux/vnc
[3] http://forums.fedoraforum.org/showthread.php?t=188625&page=2
[4] http://www.rpmfind.net/linux/rpm2html/search.php?query=selinux-policy&submit=Search+...
[5] http://linux.derkeiler.com/Mailing-Lists/Fedora/2008-07/msg01106.html
[6] http://rpm.pbone.net/index.php3/stat/26/dist/64/size/615728/name/vnc-4.1.3-1.fc9.src.rpm


BUG FIX VNC NOT RESPONDING CONTINUOUS KEY PRESS
-----------------------------------------------
See [5], need to upgrade Vnc package.
This has been resolved since installing vnc-server-4.1.2-31 from
Fedora-Updates. This coincided with an update to the xorg-x11-* packages,
so those updates could have been responsible for the fix, too. In any case,
I'm very grateful this has been corrected! :)

Download vnc-server-4.1.3-1.fc9.i386.rpm from [6]


HOW VNC SERVER PORT NUMBER IS DERIVED
-----------------------------------------
vnc port number is 5900+userDesktopIndexNumber

$vncviewer 10.1.1.10:2
Then in firewall, 5900+2 = 5902 must be enabled. [2]


BUG FIX WHY ONLY GET GREY SCREEN WHEN CONNECT VNC DESKTOP
------------------------------------------------------
Fixed bug in .vnc/localhost:localdomain:2.log
".......failed to execute message bus daemon /bin/dbus-daemon...."

Solution refer to web link [3]
upgrade selinux-policy, it solved the bug.

Details as below:

root@localhost q.yang]# rpm -q selinux-policy
selinux-policy-3.3.1-42.fc9.noarch
[root@localhost q.yang]# rpm -e selinux-policy
[root@localhost q.yang]# rpm -ivh /home/q.yang/Download/selinux-policy-3.3.1-132.fc9.noarch.rpm

Then

[root@localhost q.yang]# /sbin/service vncserver restart

[root@localhost q.yang]# vncviewer 10.1.1.5:2

Finally see the VNC desktop.

[root@localhost q.yang]# cat /home/q.yang/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
#startkde &
[root@localhost q.yang]#
[q.yang@localhost ~]$


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


1. check whether VNC installed.
[tchung@tchung101 tchung]$ rpm -q vnc vnc-server
vnc-4.0-0.beta4.3.2
vnc-server-4.0-0.beta4.3.2


If not installed, use yum install vnc

[root@QuentinFedora12 Documents]# yum install vnc-server
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.i686 0:1.0.1-1.fc12 set to be updated
--> Processing Dependency: xorg-x11-fonts-misc for package: tigervnc-server-1.0.1-1.fc12.i686
--> Running transaction check
---> Package xorg-x11-fonts-misc.noarch 0:7.2-9.fc12 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch         Version             Repository     Size
================================================================================
Installing:
 tigervnc-server           i686         1.0.1-1.fc12        updates       1.1 M
Installing for dependencies:
 xorg-x11-fonts-misc       noarch       7.2-9.fc12          fedora        5.7 M

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 6.8 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
http://ga13.files.bigpond.com:4040/fedora/linux/releases/12/Everything/i386/os/repodata/521b16256b03f708faa16735faeb724df48eb2562ba044c595add16e23288979-prestodelta.xml.gz: [Errno 14] PYCURL ERROR 7 - ""
Trying other mirror.
fedora/prestodelta                                       | 1.3 kB     00:00
updates/prestodelta                                      | 9.0 kB     00:00
Processing delta metadata
Package(s) data still to download: 6.8 M
(1/2): tigervnc-server-1.0.1-1.fc12.i686.rpm             | 1.1 MB     00:02
(2/2): xorg-x11-fonts-misc-7.2-9.fc12.noarch.rpm                          | 5.7 MB     00:12
-------------------------------------------------------------------------------------------------
Total                                                            459 kB/s | 6.8 MB     00:15
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 signature: NOKEY, key ID 57bbccba
fedora/gpgkey                                                             | 3.2 kB     00:00 ...
Importing GPG key 0x57BBCCBA "Fedora (12) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-i386
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : xorg-x11-fonts-misc-7.2-9.fc12.noarch                                                                1/2
  Installing     : tigervnc-server-1.0.1-1.fc12.i686                                                                    2/2

Installed:
  tigervnc-server.i686 0:1.0.1-1.fc12

Dependency Installed:
  xorg-x11-fonts-misc.noarch 0:7.2-9.fc12

Complete!




2. change setting

[tchung@tchung101 tchung]$ sudo vi /etc/sysconfig/vncservers

VNCSERVERS="1:q.yang 2:m.xie"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"


3. pwd
[tchung@tchung101 tchung]$ vncpasswd
Password:

4. restart vnc service

[tchung@tchung101 tchung]$ sudo /sbin/service vncserver start
Starting VNC server: 1:tchung                              [  OK  ]


[tchung@tchung101 tchung]$

Verify:


5. edit ~/.vnc/xstartup
[q.yang@QuentinFedora12 Documents]$ cat ~/.vnc/xstartup 
#!/bin/sh

vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
  exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
#startkde &





6. restart vnc service

7. change firewall to allow vnc  

NOTE: Please use GUI to do firewall settings for fedora 12 as 'iptables' has different format for fedora 9 and fedora 12. Below is iptables setting for fedora 9 ONLY.

tchung@tchung101 tchung]$ sudo vi /etc/sysconfig/iptables

# Firewall configuration written by redhat-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

[tchung@tchung101 tchung]$ sudo /sbin/service iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
[tchung@tchung101 tchung]$
8. want auto restart when linux reboot
To make VNC server to start on boot:
# chkconfig vncserver on

relevant link: http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/

Tuesday, November 18, 2008

Add new Macros in Soure Insight.

First, download Macros from http://www.sourceinsight.com/public/macros/

Macros like utils.em, comment.em,

just add utils.em into your project as one project source file, then after assigning a shortcut key to corresponding functions in utils.em, like, 'alt+(' for uncomment block of codes, 'alt+)' for comment block of codes. You can enjoy some new shortcut keys now powered by the Macros embedded into source insight.

Friday, November 14, 2008

Php+Mysql+Apache+BBS set up

START APACHE SERVER
------------------------------------------------------
[root@QuentinFedoraHome q.yang]# pwd
/home/q.yang
[root@QuentinFedoraHome q.yang]# uname -a
Linux QuentinFedoraHome 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux

[root@QuentinFedoraHome q.yang]# /opt/apache/bin/apachectl start

now, you can see your page from browser
http://10.1.1.7/


INSTALLATION OF PHP + MYSQL + APACHE
---------------------------------------------------

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep mysql

mysql-connector-java-3.1.12-5.fc9.i386

mysql-libs-5.0.51a-1.fc9.i386

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep httpd

httpd-tools-2.2.8-3.i386

httpd-2.2.8-3.i386

[q.yang@QuentinFedoraHome ~]$ rpm -qa | grep php

[q.yang@QuentinFedoraHome ~]$

uninstall mysql-connector-java-3.1.12-5.fc9.i386

[root@linuxsir01 root]#rpm -e mysql-connector-java



From: http://doc.linuxpk.com/43251.html

and http://www.linuxsir.org/bbs/showthread.php?t=77079&highlight=apache

and http://doc.linuxpk.com/5557.html



==1== Obtain software.

Download mysql-5.0.67-linux-i686-glibc23.tar.gz from:

http://dev.mysql.com/downloads/mysql/5.0.html#downloads



Download php-5.2.6.tar.gz from:

http://www.php.net/



Download httpd-2.2.10.tar.gz from:

http://apache.wildit.net.au/httpd/ mirror of appache

or from http://www.apache.org/dyn/closer.cgi to get mirror list



==2== Installation from source



以Root登录,将以上文件均拷贝至/opt/software下。

[root@xxxx opt]#mv -f /home/user/

  1.安装MySQL

[root@linuxsir01 root]# cd /opt/software

[root@linuxsir01 software]# ls mysql-4.0.16.tar.gz

[root@linuxsir01 software]#tar zxvf mysql-4.0.16.tar.gz

编译和安装:在这个地方值得注意的是,我们要把mysql-4.0.16安装到我们指定的目录中,

为了系统和安全和优化,建议把自己用源码包安装的服务器 类软件都放在/opt 目录里。

所以在这里,我们就要把mysql-4.0.16也安装到/opt/mysql这个目录中;

[root@linuxsir01 software]#cd



[root@linuxsir01 software]# cd mysql-4.0.16

[root@linuxsir01 mysql-4.0.16]#

./configure --prefix=/opt/mysql --with-mysqld-user=beinan --with-extra-charsets=all --with-unix-socket-path=/opt/mysql/var/mysql.sock



[注]关于configure的选项的一点说明:



--prefix=/opt/mysql 把mysql-4.0.16指定安装到/opt/mysql目录中;

--with-extra-charsets=all 对多语言的支持;

--with-unix-socket-path=/opt/mysql/var/mysql.sock 这个是指定mysql服务器启动后,联机套接字文件所处的位置和文件名,也就是说,如果mysql服务器成功启动后,就能在/opt/mysql/var 目录中看到mysql.sock文件。如果看不到,肯定是mysql启动不了。

--with-mysqld-user=beinan 这个是让mysql服务器也能让系统中普通用户beinan也能启动mysql服务器。当然要活学活用了:)你也可以把beinan换成你的系统中已经存 在的普通用户,比如您的系统中已经存在sir这个用户,那就把beinan替换成sir就行了。用普通用户来启动mysql的好处是:mysql的进程会 自己死掉自动退出。当然root用户也可以,不过有时mysql有些进程死了,但不会自动退出,root自己也杀不掉。所以用普通用户就有这样的好处,大 多不会出现mysql进程已死,但不会退出的情况;



[root@linuxsir01 mysql-4.0.16]#make



[root@linuxsir01 mysql-4.0.16]#make install



我们把/opt/mysql/share/mysql这个目录下的my-medium.cnf,复制为my.cnf到/etc目录下。



做了这些工作以后,还得创造MySQL授权表, 否则数据库也是启动不了。mysql_install_db,这个命令的用途就是做这个的。

[root@linuxsir01 mysql]#/opt/mysql/bin/mysql_install_db

[root@QuentinFedoraHome mysql]# ./bin/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h QuentinFedoraHome password 'new-password'

Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/



[root@QuentinFedoraHome var]# chown -R q.yang ./
[root@QuentinFedoraHome var]# ll
total 776
drwxrwx--x 2 q.yang root 4096 2009-05-21 22:54 mysql
-rwxrwx--x 1 q.yang root 125 2008-12-01 22:12 mysql-bin.000001
-rw-rw---- 1 q.yang root 106 2009-03-24 22:19 mysql-bin.000002
-rw-rw---- 1 q.yang root 106 2009-03-24 22:20 mysql-bin.000003
-rw-rw---- 1 q.yang root 125 2009-03-24 23:10 mysql-bin.000004
-rw-rw---- 1 q.yang root 106 2009-05-20 22:16 mysql-bin.000005
-rw-rw---- 1 q.yang root 125 2009-05-20 22:34 mysql-bin.000006
-rw-rw---- 1 q.yang root 106 2009-05-21 21:55 mysql-bin.000007
-rw-rw---- 1 q.yang root 125 2009-05-21 22:36 mysql-bin.000008
-rw-rw---- 1 q.yang root 18928 2009-05-21 22:23 mysql-bin.000009
-rw-rw---- 1 q.yang root 696216 2009-05-21 22:23 mysql-bin.000010
-rw-rw---- 1 q.yang root 106 2009-05-21 22:36 mysql-bin.000011
-rw-rw---- 1 q.yang root 106 2009-05-21 22:59 mysql-bin.000012
-rw-rw---- 1 q.yang root 125 2009-05-21 23:02 mysql-bin.000013
-rw-rw---- 1 q.yang root 125 2009-05-21 23:18 mysql-bin.000014
-rwxrwx--x 1 q.yang root 266 2009-05-21 23:18 mysql-bin.index
-rwxrwx--x 1 q.yang root 11477 2009-05-21 22:59 QuentinFedoraHome.err
drwxrwx--x 2 q.yang root 4096 2008-11-28 21:47 test
[root@QuentinFedoraHome var]# /opt/mysql/bin/mysql_install_db --user=q.yang --datadir=/opt/mysql/var/
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h QuentinFedoraHome password 'new-password'

Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/


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


mysql服务器启动,应该是/opt/mysql/share/mysql目录中的 mysql.server

启动方法是:

[root@linuxsir01 mysql]# /opt/mysql/share/mysql/mysql.server start



add " datadir=/opt/mysql/var" into /etc/my.cnf,

#chown smith.y /opt/mysql/var/mysql-bin.index



#mysql_install_db --user=smith.y --datadir=/opt/mysql/var



[root@linuxsir01 mysql]# /opt/mysql/share/mysql/mysql.server start --skip-grant-table

--skip-grant-table is used to avoid 'unfound mysql.plugin' error.



commented out 'skip-federated' in /etc/my.cnf to avoid error 'unknown option '--skip-federated'



changed the /etc/sysconfig/iptables, to add 3306 socket ports.

/sbin/service iptables restart Not sure whether this helped the start of MySQL server.



Now, 'Starting MySQL [OK]'



[root@QuentinFedoraHome var]# /opt/mysql/bin/mysqladmin -u root password 123456/opt/mysql/bin/mysqladmin: You cannot use 'password' command as mysqld runs with grant tables disabled (was started with --skip-grant-tables).Use: "mysqladmin flush-privileges password '*'" instead



????? how to start MySal server without --skip-grant-table



[root@QuentinFedoraHome var]# /opt/mysql/bin/mysqladmin flush-privileges password '*'/opt/mysql/bin/mysqladmin: reload failed; error: 'Table 'mysql.host' doesn't exist'



2.安装Apache、PHP3、Mod―Auth―MySQL

  由于PHP3、Mod―Auth―MySQL是作为Apache的两个模块进行编译,故Apache要与它们联合编译。

   #tar xvzf httpd-2.2.10.tar.gz(产生httpd-2.2.10目录)

  # tar xvzf php-5.2.6.tar.gz(产生php-5.2.6目录)

  # tar xvzf mod_auth_mysql-3.0.0.tar.gz(产生mod_auth_mysql-3.0.0目录)

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



  #cd httpd-2.2.10

[root@QuentinFedoraHome httpd-2.2.10]#./configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf



  # ./configure --prefix=/opt/apache(把Apache的安装目录定为/opt/apache)



 #./configure --prefix=/usr/local/apache --activate-module=src/modules/ php3/libphp3.a --activate-module=src/modules/mod―auth/libmod―auth.a   



#make; make install



[root@linuxsir01 httpd-2.0.48]#./configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf一点简单的说明:这个apache的安装,有很多的选项,如果您是比较精通,所以必要看此文,可以自己定义来安装。因为我大多是采用默认的配制,如果您想让apache有更多的功能,比如支持压缩输出以及jsp等支持,可以看其它的文章。这篇文件主还要给初学linux的弟兄写的一个简单的入门型文章,直接的说,就是给一点都不懂在linux如何安装apache,并支持php+mysql的。能让初学linux的弟兄自己架一个最简单的网站,这样弄明白原理以后,就便于深入学习和研究。我写此文的目的仅此而已;



--prefix=/opt/apache 指定把apahce安装到/opt/apache目录中;



--enable-cgi 支持CGI;



--with-config-file-path=/opt/apache/conf 指定把apache的配制文件放在/opt/apache/conf中;比如httpd.conf配制文件就在这个目录中;



--enable-track-vars 为启动cookie的get/post等追踪功能



如果需要更多的选项,可能通过下面的命令来查看;



[root@linuxsir01 httpd-2.0.48]#./configure --help



下一步就是make 和make install



[root@linuxsir01 httpd-2.0.48]#make



[root@linuxsir01 httpd-2.0.48]#make install

启动apache守护进程;

[root@linuxsir01 httpd-2.0.48]# /opt/apache/bin/apachectl start

打开浏览器,输入 http://localhost/ 就能看到一个apache的欢迎页面了,这表示我们已经成功解决了apache的安装。

back up apache config file

# cp /opt/apache/conf/httpd.conf /opt/apache/conf/httpd.confBAK

ServerAdmin beinan@linuxsir.com

ServerName 192.168.0.1:80

DocumentRoot "/var/home/freewill"

Add follows into "/etc/sysconfig/iptables"

-A INPUT -m state --state NEW -m udp -p udp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Then restart firewall

/sbin/service iptables restart

Now, you should be able to view your webpage through Internet.

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

#cd ./php-5.2.6

# ./configure --prefix=/opt/php --with-mysql=/opt/mysql --with-apxs2=/opt/apache/bin/apxs --enable-force-cgi-redirect --with-config-file-path=/opt/php/etc



#./configure --with-mysql=/usr/local/mysql --with-apache=../apache―1.3.6 --enable-track-vars

  配置PHP模块支持MySQL,并作为Apache功能模块、跟踪变量有效。

[from linuxsir ]

[root@linuxsir01 php-4.3.4]#./configure --prefix=/opt/php --with-mysql=/opt/mysql --with-apxs2=/opt/apache/bin/apxs --enable-force-cgi-redirect --with-config-file-path=/opt/php/etc

一点说明:



--prefix=/opt/php 指定把php-4.3.4安装到/opt/php目录中;

--with-mysql=/opt/mysql 指定mysql数据服务器安装的位置;

--with-apxs2=/opt/apache/bin/apxs 这是加入apache中为DSO模块的位置;

-enable-track-vars 为启动cookie的get/post等追踪功能

--with-config-file-path=/opt/php/etc 指定php的配制文件存放的目录是/opt/php/etc目录,我们安装完成后,也要把php.ini复制到这个目录中来。

  #make; make install


[root@QuentinFedoraHome php-5.2.6]# libtool --finish /opt/software/php-5.2.6/libs

[root@QuentinFedoraHome php-5.2.6]# chmod 755 /opt/apache/modules/libphp5.so

  PHP安装完毕。 

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

  #cd ./mod―auth―mysql-2.20


[root@QuentinFedoraHome software]# /opt/apache/bin/apxs -cia -L/opt/mysql/lib/mysql -I/opt/mysql/include/mysql -lmysqlclient mod_auth_mysql.c

Failed to build.

   #./configure --with-mysql=/usr/local/mysql --with-apache=../apache―1.3.6 --enable-track-vars



  配置支持MySQL、作为Apache功能模块、跟踪变量有效。

  #make (注意:这里不再用make install命令)

  Mod―Auth―MySQL安装完毕。

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

    #cp -fp /opt/software/php-5.2.6/php.ini-dist /opt/php/etc/php.ini
    #vi /opt/apache/conf/httpd.conf
       DirectoryIndex index.html index.php     "added index.php in this line -Quentin commented"
       AddType application/x-httpd-php .php     "added php application support."
AddType application/x-httpd-php-source .phps


/*


 #cd ../apache―1.3.6   #./configure --prefix=/usr/local/apache --activate-module=src/modules/ php3/libphp3.a --activate-module=src/modules/mod―auth/libmod―auth.a  #make; make install  重新编译Apache并激活PHP3模块和Mod―Auth―MySQL模块。  Apache安装完毕。


*/

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

  3.安装phpMyAdmin

  #tar -zvxf phpMyAdmin―2.0.5.tar.gz

  产生phpMyAdmin-2.11.9.5-all-languages 目录

  #mv ./phpMyAdmin-2.11.9.5-all-languages /opt/apache/htdocs/phpMyAdmin

  移到/usr/local/mysql

  #cd /opt/apache/htdocs/phpMyAdmin

  #chmod a+r * 置为可读

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


  三、软件运行



  1.启动MySQL

  第一次运行之前,先进行数据库初始化:

  #cd /usr/local/mysql

  #scripts/mysql―install―db

  #bin/safe―mysqld & (运行MySQL数据库)

  #bin/mysql -u root (默认没有设口令)

  #mysql〉use mysql; (打开MySQL数据库)



  注意,命令后的“;”是必不可少的。



  #mysql〉select * from user;

  #mysql〉exit

  这样就可以了,先不急着加口令。



  2.启动Apache

  #/usr/local/apache/bin/apachectl start



  测试:

  #telnet localhost 80



  Trying 127.0.0.1... Connected to localhost.Escape character is ′^]′.



  #cd /usr/local/apache/htdocs

  #vi test.php3



  在文件里敲入:

  〈? Echo ″HELLO WORLD!″?〉

  存盘退出,再用浏览器看一下这个文件,是不是一条问候信息?



  3. 使用phpMyAdmin

 用浏览器打开/phpMyAdmin/index.php3 (注意大小写),会出现一个简陋的界面,千万别小看它,它能完成很多让你意想不到的功能。



  四、MySQL及phpMyAdmin的设置



  1. phpMyAdmin设置

  #cd /usr/local/apache/htdocs/phpMyAdmin

  将require(″english.inc.php3″)改为require(″chinese―gb.inc.php3″)。这样就显示简体中文界面了。



  2. MySQL的用户及口令设置

  浏览/phpMyAdmin/index.php3,看到一个MySQL库,在其中的表User中,可查找当前数据库中所有用户,在Password字段中可更改Root口令。



  设置口令后,phpMyAdmin也要作相应设置:

  #vi config.inc.php3将

  $cfgServers[1][′adv―auth′]=true;

  $cfgServers[1][′stduser′]=′root′;

  $cfgServers[1][′stdpass′]=′root password′。



  五、MySQL、Apache由普通用户身份运行



  1. 运行Apache

  为Apache增加普通用户后,将Httpd.conf中的User、Group改为Apache的用户和组。

  在/etc/rc.d/rc.local中增加下面一行:

  /bin/sh -c ′/usr/local/apache/bin/apachectl start′

  使其在系统启动时自动运行Apache。



  2. 运行MySQL

  为MySQL增加普通用户后,在/etc/rc.d/rc.local中增加下面一行:

  /bin/sh -c ′/usr/local/mysql/bin/safe―mysqld --user=mysql &′

  一切准备就绪,剩下的就是使用各种工具来建立一个属于自己的网站。







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

webmin install
Install webmin using rpm, 'i'-install, 'v' -details 'h' - show progress bar.
#rpm -ivh webmin-1.470-1.noarch.rpm