Thursday, 19 April 2007
SMB/CIFS
SMB协议已经被发展成为可以运行于DOS操作系统,因此字节顺序将会和网络顺序相反。
SMB可以运行在TCP/IP,NetBEUI,DECnet和IPX/SPX协议之上。如果SMB执行于TCP/IP,DECnet或则是NetBEUI之上,那么NETBIOS名字必须被使用。
NETBIOS名字用来在网络上鉴别一台计算机。
SMB域名是用来鉴别一个SMB服务器上的一组资源的(用户,打印机,文件……)。
让我们假设一个这样的环境:一个客户端希望访问一台服务器上的特定资源。
1 - 开始于客户端向服务器请求一个NETBIOS会话。客户端发送它的已编码的NETBIOS名字到SMB服务器(它们在139端口监听连接请求)。服务器接收到NETBIOS名字后回复一个NETBIOS会话数据报给有效的会话连接。客户端在建立了连接之后才能进入访问。
2 - 客户端发送一个SMB negprot请求数据报(negprot是磋商协议“negotiate protocol”的简写)。客户端列出了它所支持的所有SMB协议版本。
3 - 通过磋商之后,客户端进程向服务器发起一个用户或共享的认证。(下一章中我们将会看到共享认证和用户认证之间的不同)。
这个过程是通过发送SesssetupX(SesssetupX是会话建立和X“Session setup and X”的简称)请求数据报实现的。客户端发送一对登录名/密码或一个简单密码到服务器,然后服务器通过发送一个SesssetupX应答数据报来允许或拒绝本次连接。
4 - 好了,在客户端完成了磋商和认证之后,它会发送一个TconX数据报并列出它想访问的特定网络资源的名称,之后服务器会发送一个TconX应答数据报以表示此次连接是否接受或拒绝。
SMB的安全等级
第一种是“共享”级的安全模式。这种安全模式需要一个访问网络上共享资源的密码。用户通过这个正确的密码来访问网络资源(IPC,磁盘,打印机)。他可以是网络上任何一个知道共享资源服务器名字的用户。
第二种是“用户”级的安全模式。这是在第一种模式上的增强版。它坚持使用一对登录名/密码来访问共享资源。所以如果一个用户想访问这种类型的共享资源,就必须同时提供登录名和密码。这种
密码
在SMB协议中,如果你想进行一次在服务器上的请求认证,你的密码可以以原码或加密后的形式发送到服务器端。如果服务器支持加密属性,客户端必须发送一个应答信号。在negprot应答数据报中,服务器会给客户端发送一个密钥。然后,客户端将密码加密并通过SesssetupX请求数据报发送到服务器端。服务器将会核查密码的有效性,并由此允许或拒绝客户端的访问。
你必须知道一个SMB密码(未加密)的最大长度是14位。密钥的长度一般为8位,加密过后的口令长度为24位。在ANSI密码中,密码中的所有位都转换成大写的形式然后再加密。
密码是以DEC编码方式进行加密的。
几种SMB数据报的描述
SMB数据报的常规特征
通常情况下,SMB运行于TCP/IP协议组之上。那么我们就假设SMB运行在TCP层之上。在TCP层上面,你常常会发现NETBIOS(NBT)头部。在NBT上面,有SMB基础报文头部。在SMB基础报文头部之上,就是另一种依赖于特定请求命令的头部。
----------------------
│ TCP Header │
----------------------
│ NETBIOS Header │
----------------------
│ SMB Base Header │----------------------
│ SMB Command Header │----------------------
│ DATA │----------------------
“SMB Base header”包含了几种信息,像接收缓冲区的长度,允许的最大连接数目……它也包含了一个鉴别请求命令的数字。
“SMB Command header”包含了所有的请求命令的参数(像磋商协议版本命令……)。
“DATA”容纳了请求命令的数据。
我们把“SMB packet”看成:NETBIOS Header + SMB Base Header + SMB Command Header+ DATA。
注意:我将使用这个定义:
typedef unsigned char UCHAR; // 8 unsigned bitstypedef unsigned short USHORT; // 16 unsigned bitstypedef unsigned long ULONG; // 32 unsigned bits
而STRING被定义为以空字符结束的ASCII字符串。
NETBIOS与SMB
NETBIOS(NETwork Basic Input and Output System)在微软的网络系统中被广泛使用。它是一个软件接口和命名系统。每台主机都有一个长度为15个字符的NETBIOS名字,且第十六个字符用来标志主机的类型(域名服务器,工作站……)。
第十六个字符的选择:
0x00 基础电脑,工作站。0x20 资源共享服务器。
这还有一些其他的值可选,不过我们对这两个最感兴趣。第一个(0x00)鉴定一台工作站,第二个(0x20)鉴定服务器。
在一个SMB数据报中,NETBIOS头部对应NETBIOS会话头部。
定义如下:
UCHAR Type; // Type of the packetUCHAR Flags; // FlagsUSHORT Length; // Count of data bytes (netbios header not included)
“Flags”域的值总是被置为0。
“Type”域有几种可能的选择:
0x81 对应一个NETBIOS会话请求。这个代码在客户端发送它的NETBIOS名字到服务器是使用。
0x82 对应一个NETBIOS会话应答。这个代码在服务器向客户端批准NETBIOS会话时使用。
0x00 对应一个会话消息。这个代码总是在SMB会话中被使用。
“Length”域包含了数据字节的长度(NETBIOS头部没有被包含在内)。数据包含在NETBIOS头部以上的所有部分(它可能是 SMB Base Header + SMB Command Header + DATA 或 NETBIOS名字)。
NETBIOS名字与编码。
NETBIOS编码名字的长度为32字节。
NETBIOS名字总是以大写的形式存在的。
编码一个NETBIOS名字非常的简单。例如我的计算机的NETBIOS名字是“BILL”,它是一个工作站,所以它的第十六个字符为“0x00”。
首先,如果一个NETBIOS名字比15字节短,就会在右边补填上空格。
“BILL “
十六进制为: 0x42 0x49 0x4c 0x4c 0x20 0x20 ......0x00
每个字节都分裂为4位一组:
0x4 0x2 0x4 0x9 0x4 0xc 0x4 0xc 0x2 0x0 .......
而且每个4位都要添加ASCII码‘A’的值(0x41)。
0x4 + 0x41 = 0x45 -> ASCII value = E0x2 + 0x41 = 0x43 -> ASCII value = C……
最后NETBIOS名字被编码为32字节长。
注意:
SMB可以直接运行于TCP之上而无须NBT(在Windows 2k和XP上它们使用455端口)。此时,NETBIOS名字没有被限制在15字符以内
STDIN
first is that, I can write script to using STDIN instand of type in by hand. for example, there is a command: smb -U username password servicename. it can lead us into the windows share dirve on Linux service platform. however, when we get into this sharedrive, we need to type command into this program, which means we are in this program. but how can I use script to execute command in sequence? using STDIN. there are two ways, first is like this to write in script:
- smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <<>
- ls
- exit
- EOF
first, script will using $1 as possward to login Central_Application_Center, then input ls, run it and exit, run again and finish to goto the next command. here EOF is a labell.
another way to write is creating another file, such as com1, we write what we want to do after we get into Central_Application_Center. so, as follow:
- smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <>
in com1:
- ls
- exit
There is another way to test when a script or program is runing well by using returning number. as follow:
- succ=0
- smb -U zliybsj2 $1 //10.2.1.21/Central_Application_Center <>
- if [ succ -ed $? ]; then
- echo running_well
- else
- echo some_mistakes_happened
- fi
here, $? stands for the retunring number of last program. so if we can complete the left part, such as however to create a pasward, the do this loop to guess, this is the most stupid way to decrypt, if for us time is not a problem. just a joking.
awk
- deal with text file which is thought of as being made up of records and fields. we can write programing by awk to do anything we want.
- we can:execute UNIX command from within a script; process the output from UNIX commands; work with multiple input streams; define functions.
- we can combined with sed and shell scripting. compared: shell is very easy and quick to write, but lacks functionality. sed, awk, and shell are designed to be integrated.
invoke:
- awk [options] 'script' var=value file(s)
- awk [options] -f scriptfile var=value file(s) : we can have more than one -f scriptfile.
- a literal: awk -f scriptFile count=5
- a shell variable: awk -f scriptFile count=$count
- A command substitution: awk -f scriptFile count=`who wc-l`
set filed seperator:
- using -F
- one line can be sperated into different filed and can be refered by variables $1, $2 etc. $0 means the whole record.
awk script consist of patterns and procedure:
- a pattern can be : /regular expression/, eg /^...:/ or relational expression, eg $1=="gdm". ~ means match, !~ means don't match, eg awk -F: '$1 ~ /.dm.*/ {print $0}' /etc/passwd. BEGIN specifies procedure to take place before the first input line is processed, END as well, eg awk ‘BEGIN {print “Version 1.0”}’ dataFile. pattern missing, the procedure applies all lines
- procedure is arround by {} and seperated by newlines or semi-colons. can be: commands, functions and veriable assignment. procedure missing, printed all lines matched by pattern.
commands used with procedures: 5 types
- Assignments of variables or arrays
- Commands that print
- Built-in functions
- Control-flow commands
- User-defined functions (in nawk only)
awk Built-in Variables:
- FILENAME - current filename
- FS - Field separator
- NF - Number of fields in current record
- NR - Number of current record
- RS - Record separator
- $0 - Entire input record
- $n - nth field in current record
awk operators: $_++_ --_ +_-_!_*_/_%_<_<=_>=_>_!=_==_~_!~_in_$$__?:_=_+=_-+_*=_/=_%=
two ways to usingarrays in awk:
- in an assignment statement: myArray[i]++
- split() function : n=splict(input,words," ") : splict this input by " "(whitespace) into words.
functions in awk: works in the same way as java: calling a function, no sapce between function name and left bracket.
Wednesday, 18 April 2007
Graphical User Interface Programming
Introduction to GUI Programming
Event-driven Programming: program responds to these events. The order of the events is determined by the user, not the program. This is similar to going to a hardware store to get components for your home improvement project. Most of the components you need already exist. All you need to do is to install them.
Java GUI Programming:A user interacts with a GUI application by causing events. The application must respond to events in the order they arrive.
Three Parts of a GUI Program:
- Graphical Components make up the Graphical User Interface.
- Listener methods receive the events and respond to them.
- Application methods do useful work for the user.
The graphical components are Swing objects. You may use them without change or may extend them to make your own classes. Listener methods and application methods are Java methods that you write. Listener methods respond to events by calling application methods. Application methods are ordinary Java methods that perform useful computations. They receive data from the GUI and send data to the GUI to be displayed, but are not usually themselves concerned with the user interface.
To write a GUI application, keep these three types of software separated (while keeping the big picture in mind). In a big software project an entire team of programmers is assigned to each of the tasks.
Container Classes: A GUI program consists of a collection of graphical components that are all placed inside one or more windows. A container is an object that can hold other GUI components. In Java terminology, a window (such as the browser window you are looking at) is a container. The buttons, sliders, icons and other GUI components are contained (by the container).
AWT Hierarchy: Some of the AWT classes derived from Component are Button, Canvas, and Container. The JComponent class is derived from Container and is one of the base classes of Swing. The JFrame class is derived from the AWT Frame class. It is usually the main container for a GUI application.
JComponent class: Objects of classes based on Container have common characteristics. They can contain components, they themselves can be placed inside containers, they can be displayed on the monitor, they generate events, they register event listeners, and so on. Since all Swing classes have Container as an ancestor, all Swing objects have these characteristics.
Swing JFrames:
Frames: In Java, a frame is a window that has nice borders, various buttons along the top border, and other features. What you usually call a "window" Java calls a "frame". A frame is a container object, so GUI components can be placed in it. a frame object is actually a section of main memory that holds information and methods. With the help of the operating system and the graphics board.
Small GUI Program
First a JFrame is created by invoking its constuctor. The argument to the constructor sets the title of the frame. The setSize(200,100) method call makes the rectangular area 200 pixels wide by 100 pixels high.
The setVisible(true) method call makes the frame appear on the screen. If you forget to do this, the frame object will exist as an object in memory, but no picture will appear on the screen. A call to setVisible(false) makes the frame invisible, but does not destroy the software object.
It is easy to forget to include setVisible(true). If you run your GUI program, and nothing happens, check that you have called this method.
The setDefaultCloseOperation() method picks the action to perform when the "close" button of the frame is clicked. This is the little button usually at the top right of the frame. If you forget to call this method with the appropriate constant, clicks on the close button will be ignored.
Running the GUI Program:
The usual way of writing a GUI is to define your own class by extending the JFrame class.
The drawString() method: When the Java system needs to paint a MyFrame object it first draws most of the picture and then calls paint() in the MyFrame object to do whatever extra the programmer wants. The first part of the work is vital. It involves interacting with the graphics of the computer system and controling the graphics board. The parameter g is a reference to a Graphics object. The Graphics object represents the part of the frame that you can draw on. When the system calls paint(), the system provides a value for this parameter. One of the methods of Graphics is drawString(String st, int X, int Y) which draws a string on the graphics area at location starting X pixels from the left and Y pixels from the top.
Buttons and Actions
JButton->AbstractButton->JComponent->Container->Component->Onject
To construct a JButton object, use new. Then add the button to the frame's content pane. The content pane is a container that represents the main rectangle of the frame. To get a reference to the content pane, use the getContentPane() method of the frame. The add method of a content pane puts a JButton (or other component) into the frame.
The ButtonFrame class does not to define a paint() method because everything in the frame is a Swing component. The system will automatically paint all components in a container when it needs to. If special processing is needed, (as with drawString() in the previous chapter), then you need to override paint().
The program in the previous chapter did not define a constructor because the constructor it inherited from its parent class JFrame was enough to do the job. ButtonFrame adds a components, and this should be done in a constructor.
Layout Manager:
When you add() buttons (and other components) to a content pane, a layout manager automatically decides what size they will be and where they will go. This is convenient, because you can add components without worrying about the details. The layout manager is like a little artist inside the computer. You say what components you want and the layout manager lays them out in the picture.
The layout manager sometimes makes odd choices. However, there are several kinds of layout managers. Each layout manager has a different style of positioning components. Usually there is a layout manager that will do the job you want. If you don't specify otherwise, a default layout manager is used.
Our program will look better if it uses the FlowLayout manager. The FlowLayout manager puts components into the frame row by row in the order they are added.
Event Listener Object
For a program to respond to an event there must be an event listener object for it. The event listener object contains listener methods for various types of events
Event Object
An event listener is an object that "listens" for events from a GUI component, like a button. An event is represented as an object. When the user generates an event, the system creates an event object, which is then sent to the listener that has been registered for the GUI component.
To be able to respond to events, a program must first:
Create an event listener object for the type of event.
Register the listener object with the GUI component that generates the event (or with a component that contains it).
ActionListener
A button listener class must implement the ActionListener interface. ActionListener is an interface (not a class) that contains the single method: public void actionPerformed( ActionEvent evt) ;
The ActionEvent parameter is an Event object that represents an event (a button click). It contains information that can be used in responding to the event. Since ActionListener is an interface, you use it with a class that will implement the actionPerformed() method. It is common to implement the interface in the same class that contains the button(s):
For the ActionListener interface, there is only one method: actionPerformed().
The repaint() method called in actionPerformed()tells the system to repaint the screen sometime soon because we have changed something. The system will do this when it is ready. Don't call paint().
The frame will be the listener for the button.
button's life in a frame:
- JButton newButton=new JButton(***) ; //create a new JButton object and assign to newButton
- newButton.addActionListener(this);//addactionlistener
- getContentPane().add(newButton);//add into JRame
- public void actionPerformed(ActionEven e){***}//action performeed. everytime, when a even happened, such as mouce moved, if such kind of event has been registed, than a even object is created and have certain action performeed, after performed, then program executes next statement or event, or this performemt will not stop. so we can see is a button is released on show which means relevant actionPerformed has been successed done. if this even is not registed, system just ingnore them.
Buttons and Action Events
setActionCommand() and getActionCommand() method refer to different action, it will pass or return String to distingish different button event. which can help us to deal with different event in actionPerformed() method.
Swing Text Fields and Labels:
A Swing Component: JTextField
A JTextField is a box that contains text. The user can type text into the box and the program can get it and then use it as data. The program can write the results of a calculation to a JTextField.
To enter text into the field you must first click the mouse pointer inside of it. This gives the field the keyboard focus (usually just called focus). When a component has focus, characters from the keyboard are directed to that component. A component gets focus by various means. The user might click it, or the program might give it focus.
JTextArea+JTextField+JEditorPane -> JTextComponent->JComponent->Container->Component->Object
The JLabel Class
In a typical application with a graphical interface, about 40% of the code manages the user interface. The rest of the code is for the application--the reason the program was written. Usually the application code is kept separate from the code that manages the interface. In a big application it would be confusing to mix the two together.
The GUI components from Swing can be used by applets.
It is a good idea to keep the GUI code and the application code in separate modules to help in debugging and understanding the program. This is also helpful if you later need to make changes to the program, say changing it from an application to an applet. The application code can be carried over without change.
The user can type into a JTextField even if it does not have a listener. getText() will still work
JPanel and BoxLayout
Each panel uses its own layout manager for the components it contains. The default layout manager of JPanel is flow layout, which is often ideal. But you may use another layout manager if appropriate.
BoxLayout Layout Manager
BoxLayout. This layout manager aligns components either horizontally or vertically within a pane. BoxLayout(Container box, int axis)
box: the container this layout manager is for axis: BoxLayout.X_AXIS -- for left to right alignment BoxLayout.Y_AXIS -- for top to bottom alignment . box is a reference to the container which will be managed by this layout manager. Often the container is a content pane.
This idea of nesting panels is a powerful one. It may look complicated and tedious, but it is much less so than laying out a design on graph paper and specifying the exact size and location of all the components. Such a design has no flexibility. What happens if you want to add or delete a component? Everything must change. With Java's layout managers everything is dynamically adjusted.
Radio Buttons, BorderLayout, and Glue
Radio Buttons
Usually radio buttons are placed in (1) a panel, to control how they are displayed, and (2) a button group, to control which buttons may be active simultaneously. A button group is an object which must be constructed. Radio buttons are then added to it.
Radio buttons generate action events which require a registered action listener. Do this as with JButtons. Use setActionCommand() to assign a command string to each button. Use addActionListener() to register a listener for each button, usually the same listener for all the buttons in a group. Use getActionCommand() in the action listener to determine which button was pushed.
BorderLayout
BorderLayout.is a frequently used layout manager. The container it manages corresponds to a rectangle on the screen. That rectangle is divided up into five regions:
- BorderLayout.NORTH,
- BorderLayout.SOUTH,
- BorderLayout.EAST,
- BorderLayout.WEST,
- BorderLayout.CENTER.
Each region may hold only one component, although that component may be a panel (and usually is). The panel may contain several components. The layout manager adjusts the size of the regions depending on what is in them. You don't have to put a component in each region. If a region has no component in it, it shrinks to a small area.
Class Box
Layout managers sometimes jam components together in a way that makes the layout look cramped. The class Box can help in this situation. A Box object is a container similar to a panel, but lacking some features. The default layout manager of Box is BoxLayout. However, the most useful features of class Box are its methods that create invisible components. These components correspond to rectangular areas of the screen. They are used as spacers to separate the visible components. If you have ever set type you know how useful spacers are in creating an attractive page. To create a fixed-sized invisible component use the method: Box.createRigidArea( new Dimension( int width, int height ) )
The parameter to createRigidArea()is a Dimension object, which does little more than hold a width and a height.
All GUI components have a getSize() method that is used to determine the dimensions of the component. The dimensions may change as a program executes, so this is a useful method. To determine the current size of a frame, use: Dimension JFrame.getSize()
Then it can look at the height and width fields of the Dimension object. Using this data it can create a rigid area of appropriate size. If this is too complicated, then use glue.
The glue component is another invisible component that class Box creates. Think of glue as stretchy caulking between components. It keeps them separated, but expands or shrinks as needed.
To create glue use one of the following:
- Box.createHorizontalGlue()
- Box.createVerticalGlue()
Class JSlider
JSlider( int orientation, int min, int max, int init )
orientation: SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
min: the minimum value. The value when the slider is at the extreme left (or very bottom) of its range.
max: the maximum value. The value when the slider is at the extreme right (or very top) of its range.
init: the initial value of the slider
- JSlide silderV=new JSlide(SwingConstants.HORIZONTAL, 0, 100, 79)
- slideV.setMajorTickSpacing(10);
- slideV.setMinorTickSpacing(10);
- sliderV.setPaintTicks(true);
- sliderV.setPaintLabels(true);
- sliderV.setSnapToTicks(true);
setPreferredSize()
The layout managers have control over the size of components, but often do their job better if you indicate a preferred size. This is done with setPreferredSize( new Dimension( int width, int height )
If this is not used, the graphical representation of a slider often has its labels and tick marks crowded together
A listener for a slider implements the ChangeListener interface. This interfaces has a single method: public void stateChanged(ChangeEvent evt)
An object that implements the interface must be registered with the slider in order to receive events: slider.addChangeListener( ChangeListener lstn )
There may be several sliders in your user interface. They all generate change events. If one change listener listens to all these events it is convenient to give the sliders names so that the events can be sorted out correctly. (Another way is to register its own listener with each slider). A name is a string that can be assigned to any object that inherits from class Component. Assign it using: component.setName( String name )
Of course you must make sure that components that share the same listener have unique names.
The Object getSource() Method
An event object contains a reference to the component that generated the event. To extract that reference from the event object use: Object getSource()
Since the return type of getSource() is Object you typically use a type cast with it: // listener method
public void stateChanged( ChangeEvent evt )
{
JSlider source;
source = (JSlider)evt.getSource();
. . . .
}
Now that you have a reference to whichever slider caused the event you can use any of the slider's methods.
Assume that the slider has a name you have set using setName(). The name of the slider is a string that is stored as part of its data. To ask the slider for its name use: String getName()
Then, to get the value of the slider use int getValue()
The value is an int between the minimum and maximum value of the slider.
In the previous application the number in the text box changes continuously as the knob is moved. Usually this is desirable. But sometimes the application calls for a great deal of work and you don't want to do it for each change event. There are (potentially) hundreds of change events generated in moving the knob from one value to the next. While the value is still changing the listener should discard the event. boolean getValueIsAdjusting()
This method returns true while the knob is still moving.
Tuesday, 17 April 2007
sed
introduction:
before this we have two method to deal with text. one is to search by using grep, however we can only show the orgainal text on screan, no modify; the other is to edit using emacs, however we need to open a new window, and all behaviour will be record which means the orgainal one can be changed easly. now, we have another one named sed which can combine both advantages.
character:
- work on terminal as command, so will not need to open a new window.
- deal with file stored in your computer or online.
- it is a lightweight stream editor, so will not using too much memoy, the result will show on scream as stdout
- Sed works by performing any number of user-specified editing operations ("commands") on the input data. Sed is line-based, so the commands are performed on each line in order. And, sed writes its results to standard output (stdout); it doesn't modify any input files.
what does sed do:
- edit input stream. the orgainal source stay same, only patch match be modified.
- produce results on standard output. modifed date can show on scream or pipled.
how does sed work:
- make a copy of orginal file. and the left steps are works on this copy not the orgainal one
- input the first line into internal bufffer.
- act command on this line and print result on scream or file. if there are more than one command being act on one line, it will execute it in sequence, which means the result of former command can be picked by the next command.
- input the next line and repeat step 2 and 3 until the while file has been acted.
how to run it from command line:
- sed [-n] [-e] 'command' file(s)
- sed [-n] -f scriptfile file(s)
formating : using regular excpressions
- ^, $, ., *, ?, [], [^]
- \{m, n\} :repeat m or more than m times, but no more than n times.
- \(, \) : group operator or regin of interest, and alwoys using with \n. often \n appear after \(, \), \n mean nth of \(, \).
sed command syntax: sed [address[,address]] [!]command [arguments]
- sed can have 0, 1, or 2 address. and can be line number, symbol or regular expression in slash. no address means applying to each input line. one address meanwhile applying to any line match this address. twp comma_separated address means form one certain line to another certain line. an address followed by ! means DO NOT match this address.
- we can put more than one sed element in a command. if first command change the buffer, the will refer to this new stuff.
flag to command:
- g: global or all occurences of something
- p: print pattern space to stdout if substitution succeddful
- n: replace the nth occurence of pattern with replacement text.
- w filename: write the pattern space of line that are changed to resultsfile if substitution succcessful.
example:
- sed '/^#/d' myfile delecte all line starting with # as comment.
- sed '/on/,/5050/d' xinetd.confsed will print the text after 5050. sed -n '/on/,/5050/d' xinetd.confsed will print nothing. sed -n '/on/,/5050/p' xinetd.confsed will print out text between on and 5050. sed '/on/,/5050/p' xinetd.confsed will print the line between on and 5050 each for twice, becasue we first print current line into buffer again, then in 5050, print again.
- s/.*// means subtitute all text found for an empty string
- who sed -n ‘s/.*(\(.*\))/\1/p’ sort > machines.txt
using different delimiters:
- sed tries to match the longest expression!
- using non-'>' character: sed -e 's/<[^>]*>//g' UST.html
character classes-posix compliant sed:
- sed ‘s/[[:space:]]//g’ myfile
- how can we just select but not subtitution or other?
Monday, 16 April 2007
google_doc
In this process, I find a quite fine tool and have to admire how great google is, that is google doc&document, which means you can use word, excell, and so on online, compared to OFFICE, we need to instal and maintain them, however you do not need to worried about these, only to using it and save online, when we using OFFICE, one problem is that the font we using on this pc maybe not instal on that pc, your word and others will fail to appear. however, it does not happened again, because all google doc&document are using same standand. maybe it will completely take market, because it can implement nearly all functions which OFFICE have, and the speed is fast at least when I use in IT_room. The favor is that we can create pdf by this, which is OFFICE can not succee. I can write pdf, modify it and read it then save on google. quite funny.
welcome to using it:http://docs.google.com/
Ubiquitous_link
London Knowledge Lab
Mark Levene
George Roussos
meanwhile, there are several link to some conferences:
Ubicomp 2007
Ubiquitous Computing (UC)
Pervasive & Ubiquitous Computing Course
language_teacher
weblink here.
convention_c_code_and_mips_code
Cconvention_c_code_and_mips_code.doc
link_to_other_or_link_to_me
name:en_version==Shao_Jianhua; cn_version==邵建华
nickname==Dustin
msn==dustin_shaojianhua@hotmail.com
mail==dustin.shaojianhua@gmail.com
qq==175190516
this_web_link==http://shaojianhua.bloggerspaces.com
==============================================
**********************************************************
==============================================
friends
wu_chengdong: crystal
java_review_and_exam_review
java_exam_review
both of them has be sant to my mailbox
no promise
---shayne ward
hey baby, when we are together,
doing things that we love.
every time you're near i feel like i'm in heaven,
feeling high
i don't want to let go, girl.
i just need you to know girl.
i don't wanna run away,
baby you're the one i need tonight,
no promises.
baby, now i need to hold you tight,
i just wanna die in your arms
here tonight
hey baby, when we are together,
doing things that we love.
everytime you're near i feel like i'm in heaven,
feeling high
i don't want to let go, girl.
i just need you to know girl.
i don't wanna run away,
baby you're the one i need tonight,
no promises.
baby, now i need to hold you tight,
i just wanna die in your arms
i don't wanna run away,
i want to stay forever,
thru time and time..
no promises
i don't wanna run away,
i don't wanna be alone
no promises
baby, now i need to hold you tight,
now and forever my love
no promises
i don't wanna run away,
baby you're the one i need tonight,
no promises.
baby, now i need to hold you tight,
i just wanna die in your arms
i don't wanna run away,
baby you're the one i need tonight,
no promises.
baby, now i need to hold you tight,
i just wanna die in your arms
here tonight.
说说blogger
我在这里说说我这几天捣鼓这个blogger的一些东西吧,因为期间我顺便学了一些html,css和javascript,之前,我所作的网页都是通过使用工具软件来做,所以很多低层次的东西我是完全不知道的。首先你要去弄这个blogger,有一个资源是非常有用的,也就是他的帮助文档,学java的时候大家都知道,他的帮助文档api是非常有用的。你可以在里面发现一些基本用法,当然还有低层次的东西,例如系统所使用的变量,这样你就可以通过使用这些变量来少做很多事情。然后还有一个很好的资源就是他的默认模板,随便选一个来分析一下,你就会发现一些共性的东西,如果你只是想简单的增加一些功能或更改布局,那就只需要在这些模板代码里面改几个数字或换几个链接。附件里的就是我分析的第一个模板template.html.
我的blogger是通过ftp发布的,因为由于政策的原因,中国是不能浏览这个页面,那他就来一个对策,通过ftp域名榜定,所以其实如果你有时间,你可以自己在本地构建好自己想要得网页,然后结合他的部分变量,然后上传到你的ftp上,那你就既可以让你的页面非常好看,功能非常强大,也可以使用blogger本身的一些功能。我就是我原来的初衷,但我学习上时间不太好安排,所以就算了。我的ftp提供是bloggerspaces,你可以去参阅一下他完整的教程。
在来说说他的内部,blogger是通过调用你的模板,结合自己数据库里面的数据来同步生成html和archieve文件,同时他使用了atom和css格式来规范你的信息。你可以通过察看你的ftp就知道了。在html中,他有一个indix.html,也就是首页,blogger在你每次修改或发新贴或有新的评论,也就是有改动的时候,系统都会对你的页面进行更改,archieve.html也是一样,每个贴为一个html页面,然后每个月的帖放在一个文件下,然后一年的帖放在一个文件目录下。最上层的,就是每天的archieve.html。此外,最上层还有一个atom.xml和css.xml文件,他们就是用来管理你的这些所有文件用的。我之前对html,xhtml,css,xml一无所知的,但花了一个下午的时间,来阅读一个网站,我就觉得其实网页编程的基础还不时很难,如果你只是想看懂网页代码的话,我觉得这个w3c网站还是很不错的。其实你还可以从上面学到别的很多东西,例如flash。里面的酷站欣赏也很不错,可是大多是都是用flash作的,公司商业嘛,可以理解。
最后在来说说模板,模版里面的东西其实也不多的,用到最多的无非就是两个东西,一个html语言,还有一个css语言,html语言实现的基础执行,css实现的是一个基本框架。所以你在css里面设计好页面由几部分组成,每一部分里面的字体,图片,填充等。然后再html语言里面放上我前面提到的系统提供的变量或别的一些你想要得东西。你去看看你就会觉得不难得,真的。我当初在search的时候,发现还有一个链接也听不错的, 你可以去看看。现在的模板所执行的标准其实也几乎都是一样的,他的标准是w3的标准。
我这里再提一个免费工具,可以提供另外一种连接显示方式,具体方法参看主页,说的已经很详细了。
关于blogger就先说到这里。