Professional Documents
Culture Documents
Sr. Page
No. Name of the Assignment No.
1 To learn & understand VB and WinSock Control. Develop a 1
client application using TCP & UDP protocols. Implement a
“Quote of the Day” Server
2 To learn & understand Internet Transfer Control in Visual 11
Basic.
To develop internet update program using Inet Control.
3 To learn & understand MAPI control. To develop a simple 20
Email application using MAPI control.
4 To learn & understand the basic concepts of web page 28
designing. To design web page using different types of tags.
5 To learn & understand XML DTD, XML Schema & XSLT. 31
To create XML DTD, XML document & XML Schema for an
application Use XSLT for formatting of XML document.
6 Learn & understand IIS/PWS/Apache server. To install and 51
configure IIS/PWS/Apache server. Study and use various
facilities/commands and features of IIS/PWS/Apache Server.
7 Develop a simple Web based application for joining report to 58
the new class. Use ASP to store the same information in
database & display the contents as per user request.
8 To learn & understand client side validation of web page. 72
9 Write a PHP Script that computes total cost of the ordered 77
items from assignment 4, after adding sales tax. The script will
show exactly what items have been ordered.
10 Write an application that should read a SQL query from the 80
user based on some database in say MySQL, call a PHP script
to process the query and display the results.
11 Write a program in C/C++ to implement an ECHO server, 88
using Socket programming with both TCP and UDP protocols.
12 Assignment to learn and understand Linux and/or Novel 96
Netware Network configurations and commands.
13 To study any protocol analyzer software (eg. LanExplorer) and 108
to learn, use its important features, Study of network
monitoring software like ETHREAL software.
14 Study of existing LAN and understand the design and various 109
components. Set up a small network of 3 to 4 computers and
Hub/Switch as directed by the instructor. Use LAN Card, UTP
Cables and Connectors. Install LAN Cards and Crimp the
connectors. Assign unique IP addresses and share C drive on
each machine. Test the network by using PING command. Use
protocol analyzer Software.
15 To learn and understand Windows 2003 server and it’s 110
associated domain operations, to configure RAS and DHCP, to
add users and computers to a domain
Assignment No: 1
OBJECTIVE:
Theory:
Possible Uses
Selecting a Protocol
When using the WinSock control, the first consideration is whether to use
the TCP or the UDP protocol. The major difference between the two lies in
their connection state:
2
• The TCP protocol control is a connection-based protocol, and is
analogous to a telephone — the user must establish a connection
before proceeding.
• The UDP protocol is a connectionless protocol, and the transaction
between two computers is like passing a note: a message is sent from
one computer to another, but there is no explicit connection between
the two. Additionally, the maximum data size of individual sends is
determined by the network.
The nature of the application you are creating will generally determine
which protocol you select. Here are a few questions that may help you select
the appropriate protocol:
To set the protocol that your application will use: at design-time, on the
Properties window, click Protocol and select either sckTCPProtocol, or
sckUDPProtocol. You can also set the Protocol property in code, as shown
below:
Winsock1.Protocol = sckTCPProtocol
3
Determining the Name of Your Computer
To connect to a remote computer, you must know either its IP address or its
"friendly name." The IP address is a series of three digit numbers
separated by periods (xxx.xxx.xxx.xxx). In general, it's much easier to
remember the friendly name of a computer.
Once you have found your computer's name, it can be used as a value for the
RemoteHost property.
When creating an application that uses the TCP protocol, you must first
decide if your application will be a server or a client. Creating a server
means that your application will "listen," on a designated port. When the
client makes a connection request, the server can then accept the request and
thereby complete the connection. Once the connection is complete, the client
and server can freely communicate with each other. The following steps
create a rudimentary server:
4
Private Sub Form_Load()
' Set the LocalPort property to an integer. Then invoke the Listen method.
tcpServer.LocalPort = 1001
tcpServer.Listen
End Sub
' Check if the control's State is closed. If not, close the connection before
tcpServer.Close
tcpServer.Accept requestID
End Sub
' The TextBox control named txtSendData contains the data to be sent.
‘ Whenever the user types into the textbox, the string is sent using the
‘ SendData method.
tcpServer.SendData txtSendData.Text
End Sub
5
' Declare a variable for the incoming data.
' Invoke the GetData method and set the Text property of a TextBox named
tcpServer.GetData strData
txtOutput.Text = strData
End Sub
' Note: to specify a remote host, you can use either the IP address (ex:
tcpClient.RemoteHost = "RemoteComputerName"
6
tcpClient.RemotePort = 1001
End Sub
tcpClient.Connect
End Sub
tcpClient.SendData txtSend.Text
End Sub
tcpClient.GetData strData
txtOutput.Text = strData
End Sub
The code above creates a simple client-server application. To try the two
together, run the project, and click Connect. Then type text into the
txtSendData TextBox on either form, and the same text will appear in the
txtOutput TextBox on the other form.
The basic server outlined above accepts only one connection request.
However, it is possible to accept several connection requests using the same
control by creating a control array. In that case, you do not need to close the
connection, but simply create a new instance of the control (by setting its
Index property), and invoking the Accept method on the new instance.
7
The code below assumes there is a Winsock control on a form named
sckServer, and that its Index property has been set to 0; thus the control is
part of a control array. In the Declarations section, a module-level variable
intMax is declared. In the form's Load event, intMax is set to 0, and the
LocalPort property for the first control in the array is set to 1001. Then the
Listen method is invoked on the control, making it the "listening control. As
each connection request arrives, the code tests to see if the Index is 0 (the
value of the "listening" control). If so, the listening control increments
intMax, and uses that number to create a new control instance. The new
control instance is then used to accept the connection request.
intMax = 0
sckServer(0).LocalPort = 1001
sckServer(0).Listen
End Sub
If Index = 0 Then
intMax = intMax + 1
Load sckServer(intMax)
sckServer(intMax).LocalPort = 0
sckServer(intMax).Accept requestID
Load txtData(intMax)
End If
End Sub
8
UDP Basics
With udpPeerA
9
‘ your computer.
.RemoteHost= "PeerB"
End With
End Sub
udpPeerA.SendData txtSend.Text
End Sub
udpPeerA.GetData strData
txtOutput.Text = strData
End Sub
10
7. Add the code below to the form.
With udpPeerB
.RemoteHost= "PeerA"
End With
End Sub
udpPeerB.SendData txtSend.Text
End Sub
udpPeerB.GetData strData
txtOutput.Text = strData
End Sub
11
To try the example, press F5 to run the project, and type into the txtSend
TextBox on either form. The text you type will appear in the txtOutput
TextBox on the other form.
As shown in the code above, you must invoke the Bind method when
creating a UDP application. The Bind method "reserves" a local port for use
by the control. For example, when you bind the control to port number 1001,
no other application can use that port to "listen" on. This may come in useful
if you wish to prevent another application from using that port.
The Bind method also features an optional second argument. If there is more
than one network adapter present on the machine, the LocalIP argument
allows you to specify which adapter to use. If you omit the argument, the
control uses the first network adapter listed in the Network control panel
dialog box of the computer's Control Panel Settings.
When using the UDP protocol, you can freely switch the RemoteHost and
RemotePort properties while remaining bound to the same LocalPort.
However, with the TCP protocol, you must close the connection before
changing the RemoteHost and RemotePort properties.
12
• Winsock1.GetData [Data], [Type], [MaxLen]: This is how you
receive all data from the Winsock control, Data = a variable, and Type
= vbString, vbInteger etc. MaxLen is optional. This can only be used
if data is sitting in the buffer, for instance using it in the
Winsock_DataArrival event is a very practical use.
• Winsock1.RemoteHostIP [IPAddress]: Use this to specify an IP
address to connect to ahead of time.
Procedure:
2. Draw two Winsock controls on the form, one for TCP & one for UDP.
3. Accept Client’s request.
4. If the request is for TCP, establish connection with Client.
5. According the client’s request, send the quote of the day.
6. If the request is UDP, send the quote of the day.
APPLICATIONS
FAQS
13
2. How to use “Winsock Control “?
Assignment No: 2
OBJECTIVES:
1. To learn & understand Internet Transfer Control in Visual
Basic.
2. To develop internet update program using Inet Control.
Theory:
Possible Uses
Basic Operation
14
However, there are a few procedures that are common to both protocols.
Basically, in order to use either protocol, you must:
In order to make any kind of connection to the Internet, you must determine
how your computer is connected to the Internet. If you are on an intranet,
you will probably be connected to the Internet via a proxy server.
Note The following steps apply only to Windows 95, Windows NT 4.0, or
later systems.
If you intend to use a proxy other than that named in the dialog box, set the
AccessType property to icNamedProxy (2). Then set the Proxy property to
the name of the proxy, as shown in the code below:
Inet1.Proxy = "myProxyName"
15
Inet1.AccessType = icNamedProxy
On the other hand, if you are content to use the default proxy (as determined
by your computer's registry), ignore the Proxy property, and simply set the
AccessType to icUseDefault (0).
After you set the AccessType property, the most basic operation is to use the
OpenURL method with a valid URL. When you use the OpenURL method,
the result will depend on the target URL. For example, the following URL
will return the HTML document found at www.microsoft.com:
Text1.Text = Inet1.OpenURL("http://www.microsoft.com")
As a result, the TextBox control is filled with the HTML source, which may
resemble the figure below:
In this case, the default action was to return the HTML document located at
the URL. However, if the URL is modified to target a specific text file, the
actual file would be retrieved. For example, the following code:
16
Tip When you use either the OpenURL or Execute method, you need not
set the Protocol property. The Internet Transfer control will automatically set
itself to the correct protocol, as determined by the protocol portion of the
URL.
Finally, you can use the OpenURL method with a URL that includes
appended data. For example, many Web sites offer the ability to search a
database. To search, send a URL that includes the search criteria. For
example, the following code would use a search engine named "search.exe"
with the criteria "find=Maui."
strURL = "http://www.megaphone43.com/cgi-bin/search.exe?find=maui
If the search engine finds a match for the criteria, an HTML document
would be assembled and returned with the appropriate information.
If you wish to save the data retrieved through the OpenURL method to a file,
use the Open, Put, and Close statements, as shown in the code below. This
example streams a binary file into a Byte array before saving the data to
disk:
strURL = "ftp://ftp.microsoft.com/Softlib/Softlib.exe"
' The result of the OpenURL method goes into the Byte array, and the Byte
array is
17
bData() = Inet1.OpenURL(strURL, icByteArray)
Close #intFile
A similar procedure can be used to write a text file to disk, except no Byte
array is needed; the data is saved directly to the file:
IntFile = FreeFile()
strURL = "http://www.microsoft.com"
As #IntFile
Close #IntFile
What does this mean for the user of the Internet Transfer control? In short,
using the OpenURL method results in a direct stream of data that you can
save to disk (as shown above), or view directly in a TextBox control (if the
18
data was text). On the other hand, if you use the Execute method to retrieve
data, you must monitor the control's connection state using the StateChanged
event. When the appropriate state is reached, invoke the GetChunk method
to retrieve data from the control's buffer. This operation is discussed in
greater detail below.
The Execute method has four arguments: url, operation, data, and
requestHeaders. FTP operations take only the operation argument and the
url argument, which is optional. For example, to get a file from a remote
computer, you could use the following code:
If you are used to using FTP to retrieve files from anonymous FTP servers,
you will be familiar with certain commands used to navigate through server
trees, and to retrieve files to a local hard disk. For example, to change
directory with the FTP protocol, you would use the command "CD" with the
path of the directory you wish to change to.
For the most common operations, such as putting a file on a server and
retrieving a file from a server, the Internet Transfer control uses the same or
a similar command with the Execute method. For example, the following
code uses the "CD" command as an argument of the Execute method to
change directory:
' The txtURL textbox contains the path to open. The txtRemotePath textbox
contains
Note When using the Execute method with FTP commands, the data and
requestHeaders arguments are not used. Instead, all of the operations and
their parameters are passed as a single string in the operation argument;
parameters are separated by a space. In the descriptions below, do not
confuse the terms "file1" and "file2" with the data and requestHeaders
arguments.
19
The syntax for FTP operations is:
For example, to get a file, the following code includes the operation name
("GET"), and the two file names required by the operation:
' Get the file named Disclaimer.txt and copy it to the location
C:\Temp\Disclaimer.txt
The following table lists the supported FTP commands of the control:
20
specified in file2.
"PUT C:\putme.txt /putme.txt"
PWD Print Working Directory. Execute , "PWD"
Returns the current directory
name. Use the GetChunk
method to return the data.
QUIT Terminate current Execute , "QUIT"
connection
RECV file1 file2 Same as GET. Execute , _
The HTTP protocol allows client machines to request data from the server
using the GET, HEAD, POST, and PUT commands. These operations are
shown in the following table:
21
Operation Description Example
GET Retrieves the file Execute "http://www.microsoft.com" & _
named in url.
"/default.htm", "GET"
HEAD Retrieves only the Execute , "HEAD"
headers of the file
named in the URL
property.
POST Provides Execute , "POST", strFormData
additional data to
support a request
to the remote host.
PUT Replaces data at Execute , "PUT", "replace.htm"
the specified URL.
The Common Gateway Interface and the Execute Method
Many World Wide Web sites offer the ability to search a database. This is
accomplished by using the HTTP protocol's ability to send queries using the
Common Gateway Interface (CGI).
It is not in the scope of this topic to explain the CGI; however, if you are
familiar with the CGI, you can use the Execute method to construct an
application that simulates the behavior of World Wide Web sites. For
example, the code below shows a typical CGI query string:
http://www.findThis2490.com/cgi-bin/find.exe?find=Hangzhou
This same query could be sent using the Execute method as shown below:
strURL = "//www.findThis2490.com/cgi-bin/find.exe"
strFormData = "find=Hangzhou"
If you are expecting a result back from a server (as in the example above),
you must use the GetChunk method to retrieve the resulting HTML
document.
22
Using the State Event with the GetChunk Method
Write As #intFile
Loop
23
Close #intFile
End Select
End Sub
FTP servers come in two flavors: public and private. Public servers, as
suggested by the name, are open to anyone. Private servers, on the other
hand, won't let you log on unless you are a bona fide user of the server. In
either case, the FTP protocol demands that you supply a user name and a
password. The two are used to authenticate a user and allow (or disallow)
subsequent actions.
With Inet1
.URL = "ftp://ftp.someFTPSite1020.com"
.Password = "mAuI&9$6"
End With
After you have invoked the Execute method, the FTP connection will remain
open. You can then continue to use the Execute method to perform other
24
FTP operations such as CD and GET. When you have completed the
session, close the connection using the Execute method with the CLOSE
operation. You can also close the connection automatically by changing the
URL property, and invoking either the OpenURL or Execute method; such
action will close the current FTP connection, and open the new URL.
Procedure:
APPLICATIONS
FAQS
25
Assignment No: 3
OBJECTIVES:
Theory:
In Visual Basic, the MAPI controls are used to interact with the underlying
message subsystem. To use these controls, you must first install a MAPI-
compliant e-mail system like Microsoft Exchange. The underlying
messaging services are provided by the workgroup environment — the
Microsoft Exchange Server running under Windows 95 (or later) or
Windows NT, for instance.
Using the MAPI controls involves two steps: establishing a MAPI session
and then using various properties and methods to access and manage an
individual Inbox. For example, create and send a message, include a file
attachment, verify the recipient's address against the e-mail system's address
book, etc.
The MAPI controls are invisible at run time. In addition, there are no events
for the controls. To use them you must set the appropriate properties or
specify the appropriate methods.
26
Note If you attempt to run a program that uses the MAPI controls, make
sure that you have the 32-bit MAPI DLLs installed properly or you may not
be able to perform MAPI functions such as SignOn. For example, on
Windows 95 or later, you must install Exchange during the operating system
setup, or install it separately from the control panel to correctly use MAPI
functions.
Possible Uses
You can set the MAPISession properties at design time using the
MAPISession Property Pages. Right-click the MAPISession control and
click Properties to display the Property Pages dialog box.
The UserName and Password properties are used to provide a valid sign-on
to the underlying messaging system. You can either set these properties at
design time or prompt the user at run time. Setting the LogonUI property to
True will provide the user with the sign-on dialog box of the underlying mail
system. If such a dialog box does not exist, this property will be ignored.
You can create a custom dialog box to prompt the user for this information.
27
The DownloadMail property specifies whether the user's mail will be
downloaded at the beginning of the current session automatically. Setting
this value to True will download all the user's mail to their Inbox. Depending
upon the mail system and the amount of incoming mail, this can be a
processing-intensive operation. By setting this property to False, the user can
choose to download mail at a later time or set the interval at which mail is
automatically downloaded.
Once the UserName and Password properties have been set, use the SignOn
method at run time to begin the MAPI session.
For example:
mpsSession.SignOn
Note The Action property can also be used to sign in and out of a MAPI
session. It is recommended, however, that you use the SignOn and SignOff
methods instead. The Action property is included for compatibility with
earlier versions of Visual Basic.
28
Using the MAPIMessages Control
You can, however, use the MAPI controls to create very powerful mail-
enabled and workgroup applications.
mpmMessage.SessionID = mpsSession.SessionID
This association to a valid MAPI session must be made before you can
access messages and begin working with the MAPIMessages control.
Accessing Messages
29
MAPISession control. The Inbox is the message store. When the Inbox is
opened two buffers are created: the compose buffer and the read buffer.
The read buffer is made up of an indexed set of messages fetched from the
user's Inbox. The MsgIndex property is used to access individual messages
within this set, starting with a value of 0 for the first message and
incrementing by one for each message through the end of the set.
The message set is built using the Fetch method. The set includes all
messages of type FetchMsgType and is sorted as specified by the
FetchSorted property. The value of the FetchMsgType property is controlled
by the underlying message system. The FetchSorted property can be set to
add messages to the message set (read buffer) in the order they are received
or in the order specified by the user's Inbox. Previously read messages can
be included or left out of the message set with the FetchUnreadOnly
property.
Messages in the read buffer can't be altered by the user, but can be copied to
the compose buffer for alteration.
Messages are created or edited in the compose buffer. The compose buffer is
active when the MsgIndex property is set to –1. Many of the messaging
actions are valid only within the compose buffer, such as sending messages,
saving messages, or deleting recipients and attachments.
30
Composing and Managing Messages
Method Description
Compose Composes a new message
Copy Copies the currently indexed message to the compose
buffer
Delete Deletes a message, recipient, or attachment
Fetch Creates a message set from selected messages in the
Inbox
Forward Forwards a message
Reply Replies to a message
ReplyAll Replies to all message recipients
Save Saves the message currently in the compose buffer
Send Sends a message
Managing messages is the primary function of the MAPIMessages control.
Composing, sending, receiving, and deleting messages are performed by
using methods that correspond to these basic functions (compose, copy,
delete, etc.). The following table lists the MAPIMessages methods that
specifically apply to messages:
None of the other message properties can be set until a message is selected
with the MsgIndex property. The index number can range from –1 to
MsgCount –1 (the MsgCount property returns the total number of messages
in the message set.) When a new message is created, the value of the
MsgIndex property is set to –1.
Composing a Message
Use the Compose method to create a new message. When the Compose
method is used, the compose buffer is cleared and the MsgIndex property is
set to –1.
31
mpmMessage.Compose
To set the recipient's name and address, use the RecipDisplayName and the
RecipAddress properties. The RecipDisplayName is the proper name of the
recipient, for example, "Richard Tull". The RecipAddress property contains
the recipient's e-mail address: "richtull", for example.
'Address message
mpmMessage.RecipAddress = "richtull"
mpmMessage.AddressResolveUI = True
mpmMessage.ResolveName
32
recipient address is encountered when the message is sent. The details dialog
box will offer you an alternative address if a close match is found.
The MsgSubject property specifies the subject line for the message. You
may enter up to 64 characters, including the Null character.
By accessing messages in the read buffer you can sort, delete, or forward
one or a number of messages. The following table lists the properties you
can use to manage messages:
Property Description
MsgConversationID Specifies the conversation thread identification value
for the currently indexed message.
MsgCount Returns the total number of messages present in the
message set during the current messaging session.
33
MsgDateReceived Returns the date on which the currently indexed
message was received.
MsgID Returns the string identifier of the currently indexed
message.
MsgIndex Specifies the index number of the currently indexed
message.
MsgOrigAddress Returns the mail address of the originator of the
currently indexed message.
MsgOrigDisplayName Returns the originator's name for the currently
indexed message.
MsgRead Returns a Boolean _expression indicating whether
the message has already been read.
MsgReceiptRequested Specifies whether a return receipt is requested for
the currently indexed message.
MsgSent Specifies whether the currently indexed message has
already been sent to the mail server for distribution.
MsgType Specifies the type of the currently indexed message.
To send the message, use the Send Method. The Send method allows you to
send a message with or without user interaction. Setting the value to True
will display the compose message dialog box of the underlying e-mail
system (Microsoft Exchange, for example). Setting it to False will send the
message without displaying the compose message dialog. The following
example sends the message without prompting for user interaction:
mpmMessage.Send False
APPLICATIONS
FAQS
34
Assignment No: 4
OBJECTIVES:
Theory:
HTML Tags
HTML defines a lot of elements for formatting output, like bold or italic
text.
35
<big> Defines big text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
<s> Deprecated. Use <del> instead
<strike> Deprecated. Use <del> instead
<u> Deprecated. Use styles instead
HTML Tables :
Tables are defined with the <table> tag. A table is divided into rows (with
the <tr> tag), and each row is divided into data cells (with the <td> tag). The
letters td stands for "table data," which is the content of a data cell. A data
cell can contain text, images, lists, paragraphs, forms, horizontal rules,
tables, etc.
Table Tags
Tag Description
<table> Defines a table
<th> Defines a table header
<tr> Defines a table row
<td> Defines a table cell
<caption> Defines a table caption
<colgroup> Defines groups of table columns
<col> Defines the attribute values for one or more columns in a table
<thead> Defines a table head
<tbody> Defines a table body
<tfoot> Defines a table footer
36
With HTML you can display images in a document.
Image Tags
Tag Description
<img> Defines an image
<map> Defines an image map
<area> Defines a clickable area inside an image map
Forms
Form elements are elements that allow the user to enter information (like
text fields, textarea fields, drop-down menus, radio buttons, checkboxes,
etc.) in a form.
Form Tags
Tag Description
<form> Defines a form for user input
<input> Defines an input field
<textarea> Defines a text-area (a multi-line text input control)
<label> Defines a label to a control
<fieldset> Defines a fieldset
<legend> Defines a caption for a fieldset
<select> Defines a selectable list (a drop-down box)
<optgroup> Defines an option group
<option> Defines an option in the drop-down box
<button> Defines a push button
<isindex> Deprecated. Use <input> instead
Procedure:
37
APPLICATIONS
FAQS
Assignment No: 5
OBJECTIVES:
Theory:
38
XML was designed to describe data and to focus on what data is. HTML
was designed to display data and to focus on how data looks.
What is XML?
XML was designed to store, carry, and exchange data. XML was not
designed to display data.
The syntax rules of XML are very simple and very strict. The rules are very
easy to learn, and very easy to use.
Because of this, creating software that can read and manipulate XML is very
easy.
39
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</note>
The first line in the document - the XML declaration - defines the XML
version and the character encoding used in the document. In this case the
document conforms to the 1.0 specification of XML and uses the ISO-8859-
1 (Latin-1/West European) character set.
The next line describes the root element of the document (like it was saying:
"this document is a note"):
<note>
The next 4 lines describe 4 child elements of the root (to, from, heading, and
body):
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
And finally the last line defines the end of the root element:
</note>
Can you detect from this example that the XML document contains a Note
to Tove from Jani? Don't you agree that XML is pretty self-descriptive?
40
XML Elements
<note>
<to>Tove</to>
<from>Jani</from>
</note>
41
All XML documents must have a root element.
Attribute values must always be quoted.
With XML, white space is preserved.
With XML, CR / LF is converted to LF.
XML documents are Extensible.
XML Elements have Relationships
Elements are related as parents and children.
Elements have Content
Elements can have different content types.
In the example above, book has element content, because it contains other
elements. Chapter has mixed content because it contains both text and other
elements. Para has simple content (or text content) because it contains only
text. Prod has empty content, because it carries no information.
XML Attributes
XML elements can have attributes in the start tag, just like HTML.
Element Naming
XML DTD
42
The purpose of a DTD is to define the legal building blocks of an XML
document. It defines the document structure with a list of legal elements
<?xml versionfiltered="1.0"?>
<!DOCTYPE note [
<!ELEMENT to (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
43
<heading>Reminder</heading>
</note>
!DOCTYPE note (in line 2) defines that this is a document of the type
note.
!ELEMENT note (in line 3) defines the note element as having four
elements: "to,from,heading,body".
!ELEMENT to (in line 4) defines the to element to be of the type
"#PCDATA".
!ELEMENT from (in line 5) defines the from element to be of the type
"#PCDATA"
and so on.....
This is the same XML document as above, but with an external DTD
<?xml versionfiltered="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
44
<XBODY>DON'T p weekend!<xbody>< this me forget>
</note>
<!ELEMENT to (#PCDATA)>
With DTD, each of your XML files can carry a description of its own format
with it.
With a DTD, independent groups of people can agree to use a common DTD
for interchanging data.
Your application can use a standard DTD to verify that the data you receive
from the outside world is valid.
The main building blocks of both XML and HTML documents are tags like
<XBODY>....<XBODY>.< p>
Seen from a DTD point of view, all XML documents (and HTML
documents) are made up by the following simple building blocks:
• Elements
• Tags
45
• Attributes
• Entities
• PCDATA
• CDATA
Elements
Elements are the main building blocks of both XML and HTML
documents.
Tags
Examples:
Attributes are always placed inside the starting tag of an element. Attributes
always come in name/value pairs. The following "img" element has
additional information about a source file:
46
<img src=http://mail.yahoo.com/config/login?/"computer.gif" />
The name of the element is "img". The name of the attribute is "src". The
value of the attribute is "computer.gif". Since the element itself is empty it is
closed by a " /".
Entities
Entities are variables used to define common text. Entity references are
references to entities.
Most of you will know the HTML entity reference: " ". This "no-
breaking-space" entity is used in HTML to insert an extra space in a
document. Entities are expanded when an XML parser parses a document.
PCDATA
Think of character data as the text found between the start tag and the end
tag of an XML element.
PCDATA is text that will be parsed by a parser. Tags inside the text will
be treated as markup and entities will be expanded.
CDATA
47
CDATA is text that will NOT be parsed by a parser. Tags inside the text
will NOT be treated as markup and entities will not be expanded
DTD – Elements
Declaring an Element
or
example:
<!ELEMENT br EMPTY>
XML example:
<br />
Elements with only character data
Elements with only character data are declared with #PCDATA inside
parentheses:
example:
48
Elements with any contents
Elements declared with the category keyword ANY, can contain any
combination of parsable data:
example:
Elements with one or more children are defined with the name of the
children elements inside parentheses:
<!ELEMENT element-name
(child-element-name)>
or
<!ELEMENT element-name
(child-element-name,child-element-name,.....)>
example:
<!ELEMENT to (#PCDATA)>
49
<!ELEMENT heading (#PCDATA)>
Declaring Attributes
attribute-type default-value>
example:
DTD example:
XML example:
Value Explanation
CDATA The value is character data
(en1|en2|..) The value must be one from an enumerated list
ID The value is a unique id
IDREF The value is the id of another element
IDREFS The value is a list of other ids
NMTOKEN The value is a valid XML name
NMTOKENS The value is a list of valid XML names
ENTITY The value is an entity
ENTITIES The value is a list of entities
50
NOTATION The value is a name of a notation
xml: The value is a predefined xml value
Value Explanation
value The default value of the attribute
#REQUIRED The attribute value must be included in the element
#IMPLIED The attribute does not have to be included
#FIXED value The attribute value is fixed
Enumerated attribute values
Syntax:
<!ATTLIST element-name
DTD example:
XML example:
or
Use enumerated attribute values when you want the attribute values to be
one of a fixed set of legal values
XML Schema
51
An XML schema describes the structure of an XML document.
An XML Schema:
There are a number of reasons why XML Schema is better than DTD.
XSD How To
52
<?xml versionfiltered="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</note>
A Simple DTD
This is a simple DTD file called "note.dtd" that defines the elements of the
XML document above ("note.xml"):
<!ELEMENT to (#PCDATA)>
Line 1 defines the note element to have four elements: "to, from, heading,
body". Line 2-5 defines the to element to be of the type "#PCDATA", the
from element to be of the type "#PCDATA", and so on...
This is a simple XML Schema file called "note.xsd" that defines the
elements of the XML document above ("note.xml"):
<?xml versionfiltered="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
53
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml versionfiltered="1.0"?>
54
<xs:schema>
...
...
</xs:schema>
XSD Elements
1. Simple Elements
XML Schemas define the elements of your XML files.A simple element is
an XML element that can contain only text. It cannot contain any other
elements or attributes.
where xxx is the name of the element and yyy is the data type of the
element.
<lastname>Refsnes</lastname>
<age>34</age>
<dateborn>1968-03-27</dateborn>
55
<xs:element name="lastname" type="xs:string"/>
• empty elements
• elements that contain only other elements
• elements that contain only text
• elements that contain both other elements and text
<product pid="1345"/>
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
56
<food type="dessert">Ice cream</food>
<description>
</description>
How to Define a Complex Element
Look at this complex XML element, "employee", which contains only other
elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
</xs:sequence>
57
</xs:complexType>
</xs:element>
If you use the method described above, only the "employee" element can use
the specified complex type. Notice that the child elements, "firstname" and
"lastname", are surrounded by the <sequence> indicator. This means that the
child elements must appear in the same order as they are declared;
"firstname" first and "lastname" second.
2. The "employee" element can have a type attribute that refers to the name
of the complex type to use:
<xs:complexType name="personinfo">
<xs:sequence>
</xs:sequence>
</xs:complexType>
XSD Attributes
58
What is an Attribute?
where xxx is the name of the attribute and yyy is the data type of the
attribute.
<lastname lang="EN">Smith</lastname>
XML Schema has a lot of built-in data types. Here is a list of the most
common types:
• xs:string
• xs:decimal
• xs:integer
• xs:boolean
• xs:date
• xs:time
59
Procedure :
APPLICATIONS
FAQS
60
Assignment No: 6
OBJECTIVES:
Theory:
This section concerns installing Microsoft's Personal Web Server (PWS) 4.0
on Windows 98 SE, since that's the system I had available to install and test
on. PWS is also available for Windows 95 and NT.
There are two places you can get PWS, both of which are free. The
Windows 98 CD includes it, and you can download it from the Microsoft
web site.
61
Warning 2: There is a fairly rare problem with MTS that may cause you
problems later.
Downloading from Microsoft.com
If you don't have the Windows 98 CD, you can download the NT4 Option
Pack which, believe it or not, contains Personal Web Server for Windows 95
and 98.
Be aware that the download is 34mb, which will take nearly 3 hours to
download with a 28.8 modem.
The Windows 98 CD includes PWS, but you need to run a separate setup
program to fully install and configure it. Microsoft recommends that you
have at least a 90 MHz Pentium processor with 20-32 MB RAM, 40MB free
disk space and a Super VGA monitor
62
The custom installation has all the Typical components selected, so all we
need to do is find the checkbox for the ASP documentation, and check it! It's
3 levels down…
Highlight "Personal Web Server (PWS)", being careful not to uncheck the
box, then choose "Show Subcomponents…"
Check the checkbox next to "Active Server Pages", then choose OK.
Choose OK once more, and then Next to continue with the next step of the
installation.
Accept the default path, or change it - it's up to you! I recommend using the
default.
After waiting for the installation to complete, you'll be asked to restart your
computer (but wait just a minute).
When you do, you'll see something new in your system tray on the taskbar,
which shows that your PWS is now up and running. Congratulations!
A quick way to test it is to go to the following URL - write this down, and
bookmark it in your browser later - http://localhost/iishelp. This brings up
the excellent help that covers PWS and has a handy ASP reference too.
Note: On some systems that URL has been reported as not working, so use
the longhand version instead:
http://localhost/iishelp/pws/misc/default.asp
63
3. Use a text editor to write some ASP code, save the file as "test1.asp"
in the "MyWeb" folder.
4. Make sure your Web server is running - The installation program has
added a new icon on your task bar (this is the PWS symbol). Click on
the icon and press the Start button in the window that appears.
Okay, enough with the sales pitch, let's install this baby.
Start -> Settings -> Control Panel -> Add/Remove Programs ->
Add/Remove Windows Components
Some of the components you do not need, but for this example, we'll install
the whole IIS package since we want the webserver, FTP server, and mail
capabilities
Click on "Next” The dialog box will show files being copied to your hard
disk.
After a few moments, you'll get this dialog box that ask you to insert the
Windows 2000 CD into your CD-ROM drive. Put in the CD then click
"OK".
64
The files will continue to be copied. This could take a while. When
everything is done, you'll see this screen. Click on "Finish".
Then all the windows close and you're left staring at your blank desktop
again. In order to go configure your website, you need to go:
Start -> Settings -> Control Panel -> Administrative Tools -> Internet
Service Manager
The other way to manage your website is through the "Personal Web
Manager".
This is a scaled back version of the "Internet Service Manager" and it cannot
control your FTP or mail services, so I do not recommend using it.
However, it does have a cool bar graph showing how many people and
connections you have to your website so that is pretty interesting.
The "Advanced Options" here is also much thinner than the Internet Service
Manager.
Double click on "Internet Service Manager" and let's get started. Click on
the name of your computer to see the summary of what's going on with your
computer. In my case, my computer is called "Brian" so the name I see and
click on is "*brian".
Since we chose to install all the IIS components, you will see the Web, FTP,
and SMTP mail server all running. You can disable a particular service
(Web, FTP, or SMTP) by right clicking on the service and choosing "pause"
or "stop".
You'll notice under "IP Address" it says "All Unassigned” This means that
all requests to your server will be answered by your computer. If for some
reason your server has several IP addresses, you will want to specify the
exact IP address that the Internet Services is supposed to respond to.
65
If your computer only has 1 IP address, we can leave the IP address as "All
Unassigned".
Let's take a look at the Web Service. Right click on "Default Web Site" then
select "Properties".
As you explore the different tabs, you'll notice that there are several boxes
and options that are grayed out. These options are only available in the
Server Editions like Windows 2000 Server and Advanced Server.
Since there are so many options I'll just hit the major points.
Each visitor creates 2-3 connections so this means your webserver using this
software is limited to 3-4 concurrent visitors which should not be a problem
for a small website
Tab: Performance
66
Tab: Documents
There is a list of default documents that the webserver will look for when a
visitor accesses a directory. The starting point of your website must be
listed here. You can either rename your first page of your website to
Default.htm or another defualt document type that you specify.
Traditionally, the first page of most websites is "index.html" so you can add
that to the list and promote it to the top using the up arrow on the left side.
We can now check to see if your web service is working correctly. From
your web browser from the same machine, type in the name of your
computer or the IP number of your computer.
Install Apache
1.Run apache_2.0.55-win32-x86-no_ssl.msi.
2.Choose "I accept the terms in the license agreement", and then click Next
>.
67
3.Click Next >.
4.Fill in the appropriate information. Select "for All Users, on Port 80, as a
Service", and then click Next >. If you do not know what to enter, you can
put in "localhost" for the network domain and server name.
7. Click Install.
8. Click Finish
Test:
2. You'll also notice a new icon in your system tray. If you single left-click,
you'll get a menu that allows you to start, stop, or restart the Apache HTTPD
service.
Apache stores it's configuration settings in a file called httpd.conf. This file
is located at C:\Program Files\Apache Group\Apache2\conf. The file is well
documented so feel free to snoop around. You can learn a lot just by looking
through it.
Although for this tutorial I left it alone, I usually change the default
document root. This is where all of your website's files are stored. To change
the document root
1. Change line 228. Notice that for Windows, you convert the
backslashes to regular slashes. i.e. \ to /.
68
2. Change line 253 to match the same path as before.
APPLICATIONS
FAQS
cc
69
Assignment No: 8
OBJECTIVES:
Theory:
What is JavaScript?
70
• JavaScript can read and write HTML elements - A JavaScript can
read and change the content of an HTML element
• JavaScript can be used to validate data - A JavaScript can be used
to validate form data before it is submitted to a server, this will save
the server from extra processing
• JavaScript can be used to detect the visitor's browser - A
JavaScript can be used to detect the visitor's browser, and - depending
on the browser - load another page specifically designed for that
browser
JavaScript Functions
To keep the browser from executing a script as soon as the page is loaded,
you can write your script as a function.
You may call a function from anywhere within the page (or even from other
pages if the function is embedded in an external .js file).
Example
<html>
<head>
<script type="text/javascript">
function displaymessage()
{
alert("Hello World!")
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!"
onclick="displaymessage()" >
71
</form>
</body>
</html>
If the line: alert("Hello world!!"), in the example above had not been written
within a function, it would have been executed as soon as the line was
loaded. Now, the script is not executed before the user hits the button. We
have added an onClick event to the button that will execute the function
displaymessage() when the button is clicked.
How to Define a Function
function functionname(var1,var2,...,varX)
{
some code
}
var1, var2, etc are variables or values passed into the function. The { and the
} defines the start and end of the function.
function functionname()
{
some code
}
The return statement is used to specify the value that is returned from the
function.
So, functions that are going to return a value must use the return statement.
72
Example
The function below should return the product of two numbers (a and b):
function total(a,b)
{
x=a*b
return x
}
When you call the function above, you must pass along two parameters:
product=total(2,3)
The returned value from the total() function is 6, and it will be stored in
the variable called product.
Events
Every element on a web page has certain events which can trigger JavaScript
functions. For example, we can use the onClick event of a button element to
indicate that a function will run when a user clicks on the button. We define
the events in the HTML tags.
Examples of events:
• A mouse click
• A web page or an image loading
• Mousing over a hot spot on the web page
• Selecting an input box in an HTML form
• Submitting an HTML form
• A keystroke
Note: Events are normally used in combination with functions, and the
function will not be executed before the event occurs!
73
onload and onUnload
The onload and onUnload events are triggered when the user enters or leaves
the page.
The onload event is often used to check the visitor's browser type and
browser version, and load the proper version of the web page based on the
information.
Both the onload and onUnload events are also often used to deal with
cookies that should be set when a user enters or leaves a page. For example,
you could have a popup asking for the user's name upon his first arrival to
your page. The name is then stored in a cookie. Next time the visitor arrives
at your page, you could have another popup saying something like:
"Welcome John Doe!".
The onFocus, onBlur and onChange events are often used in combination
with validation of form fields.
onSubmit
The onSubmit event is used to validate ALL form fields before submitting it.
74
onMouseOver and onMouseOut
<a href="http://www.w3schools.com"
onmouseover="alert('An onMouseOver event');return false">
<img src="w3schools.gif" width="100" height="30">
</a>
Procedure :
75
Assignment No: 9
Problem Statement:
Write a PHP Script that computes total cost of the ordered items from
assignment 4, after adding sales tax. The script will show exactly what items
have been ordered.
Theory:
PHP is a powerful tool for making dynamic and interactive Web pages.
What is PHP?
Why PHP?
76
• PHP is compatible with almost all servers used today (Apache, IIS,
etc.)
• PHP is FREE to download from the official PHP resource:
www.php.net
• PHP is easy to learn and runs efficiently on the server side
Where to Start?
A PHP file normally contains HTML tags, just like an HTML file, and some
PHP scripting code.
Below, we have an example of a simple PHP script which sends the text
"Hello World" to the browser:
<html>
<body>
<?php echo "Hello World"; ?>
</body>
</html>
A PHP scripting block always starts with <?php and ends with ?>. A PHP
scripting block can be placed anywhere in the document.
Each code line in PHP must end with a semicolon. The semicolon is a
separator and is used to distinguish one set of instructions from another.
There are two basic statements to output text with PHP: echo and print. In
the example above we have used the echo statement to output the text "Hello
World".
The most important thing to notice when dealing with HTML forms and
PHP is that any form element in an HTML page will automatically be
available to your PHP scripts.
77
Look at the following example of an HTML form:
<html>
<body>
<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
The example HTML page above contains two input fields and a submit
button. When the user fills in this form and hits the submit button, the
"welcome.php" file is called.
<html>
<body>
Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old!
</body>
</html>
Welcome John.
You are 28 years old!
Note: If the method attribute of the form is GET, then the form information
will be set in $_GET instead of $_POST.
Procedure :
78
FAQ:
What is PHP?
Assignment No: 10
Problem Statement:
Write an application that should read a SQL query from the user based on
some database in say MySQL, call a PHP script to process the query and
display the results.
Theory:
79
ODBC is an Application Programming Interface (API) that allows you to
connect to a data source (e.g. an MS Access database).
Note that this configuration has to be done on the computer where your web
site is located. If you are running Internet Information Server (IIS) on your
own computer, the instructions above will work, but if your web site is
located on a remote server, you have to have physical access to that server,
or ask your web host to to set up a DSN for you to use.
Connecting to an ODBC
Example:
$conn=odbc_connect('northwind','','');
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
80
Retrieving Records
The function takes two parameters: the ODBC result identifier and an
optional row number:
odbc_fetch_row($rs)
The odbc_result() function is used to read fields from a record. This function
takes two parameters: the ODBC result identifier and a field number or
name.
The code line below returns the value of the first field from the record:
$compname=odbc_result($rs,1);
The code line below returns the value of a field called "CompanyName":
$compname=odbc_result($rs,"CompanyName");
odbc_close($conn);
An ODBC Example
The following example shows how to first create a database connection, then
a result-set, and then display the data in an HTML table.
<html>
81
<body>
<?php
$conn=odbc_connect('northwind','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>Companyname</th>";
echo "<th>Contactname</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>
</body>
</html>
What is MySQL?
PHP + MySQL
• PHP combined with MySQL are cross-platform (means that you can
develop in Windows and serve on a Unix platform)
82
Where to Start?
So lets first start creating a file by assigning values for the server, the
database, the user name and password to variables. Let us save this file as
'conn.php'.
<?php
$strServer="66.9.65.200"; // Server IP Address 'or' Name
$strDatabase="database name"; // Database Name
$strUser="root"; // User ID
$strPwd="pwd"; // Password
?>
Syntax:
$strDB=mysql_connect("ServerIP Address","Username","Password");
Example:
$strDB=mysql_connect($strServer,$struser,$strPwd);
83
function 'mysql_close' is used for closing a database connection which has
been opened. It takes the 'link identifier' as its argument and returns 'True' on
success and 'False' on Error.
Syntax:
mysql_select_db("Database Name",$strDB);
Example:
$database=mysql_select_db("strDatabase",$strDB);
Syntax:
Example:
mysql_close($strDB);
<?php
include("conn.php")
$strDB=mysql_connect($strServer,$struser,$strPwd);
$database=mysql_select_db("$strDatabase",$strDB);
'conn.php'
<?php
$strServer="66.9.65.200"; // Server IP Address 'or' Name
$strDatabase="database name"; // Database Name
$strUser="root"; // User ID
$strPwd="pwd"; // Password
?>
84
That's it you've learnt how to connect MySQL Database from PHP.
Syntax:
Example:
The Select command is used to select the records from a table using its field
names. To select all the fields in a table, '*' is used in the command. The
result is assigned to a variable name as shown below:
Syntax:
Example:
85
DELETE Command
The Delete command is used to delete the records from a table using
conditions as shown below:
Syntax:
Example:
The Insert command is used to insert records into a table. The values are
assigned to the field names as shown below:
Syntax:
Example
$insertSQL=("INSERT INTO
Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) ");
UPDATE Command
The Update command is used to update the field values using conditions.
This is done using 'SET' and the fieldnames to assign new values to them.
Syntax:
Example:
86
DROP Command
The Drop command is used to delete all the records in a table using the table
name as shown below:
Syntax:
$dropSQL=("DROP tblName");
Example
$dropSQL=("DROP tblstudent");
Procedure :
1. The web server receives the request via HTTP for a particular web
page and resolves and retrieves the requested file.
2. Depending on the nature of the file (i.e., if it ends in .php), it is pre-
processed using, in our case, the PHP engine.
3. The script's application and presentation logic executes, performing
database queries as necessary.
4. The PHP engine uses the results from the database in its application
logic to construct the HTML document, returning it to the web server
and, finally, the client.
We will focus on steps three and four in our discussions here. Looking at
those steps in more detail, we can summarize the process of accessing and
working with a database connection from within a PHP script in the
following steps. (The steps in parentheses are optional, depending on
circumstance.)
87
• (Retrieve and process the results.)
• Create HTML or perform actions based on results.
• (Close the database connection.)
FAQ:
1.What is ODBC?
Assignment No: 11
Problem Statement:
88
Write a program in C/C++ to implement an ECHO server, using Socket
programming with both TCP and UDP protocols.
Theory:
Used a combination of existing Unix system calls and some new ones
Client/server model
89
Each process has a socket.
At each end, the socket appears to be two byte streams, one for reading and
one for writing. It is represented by a Unix file descriptor, so normal file I/O
system calls (read, write) can be used.
format of messages
meaning of messages
Establishing a connection:
The server accepts the connection, gets a file descriptor to represent the
server-side socket.
The client connection request returns, passing to the client a file descriptor to
represent the client-side socket.
bind
90
listen
accept
connect
socket: create a socket. (The created socket is not connected. This call just
makes an entry in a table in the kernel.)
http: 80
ftp: 21
telnet: 23
listen: used by servers to make a socket into a listening socket that will listen
for connection requests from clients.
Note: A client must create a socket before calling connect, but does not need
to bind it to a local address. The client socket is assigned to an "ephemeral"
port number by the TCP/IP software.
Server:
Client:
create socket
91
bind to local address
loop
accept connection
get request
send response
close connection
end loop
create socket
request connection
get reply
send request
get response
close connection
92
Returns a file descriptor if successful, -1 if error. The file descriptor is used
to identify the socket in subsequent calls.
Possible errors:
time out
connection refused
already connected
struct sockaddr {
};
93
struct sockaddr_in {
};
94
int * addrlen); // address of local variable to be filled in with length of
client's socket address
Also of interest are the low-level Unix system calls for reading and writing
files (if you haven't seen these before):
Several additional system calls are available which are designed specifically
for writing to and reading from sockets.
char * buffer,
int len,
int flags);
95
Equivalent to a write operation with one additional parameter. The flags
parameter may be used to indicate "out-of-band" data.
char * buffer,
int len,
int flags);
Procedure:
96
6. Receive reply from echo server using “read” function..
7. Close the socket.
Assignment No: 12
Problem Statement:
Theory:
97
TIP 1. When you need to find a particular file/directory then use the 'locate'
command (on Fedora slocate works well too) to find things on your server.
Like, typing: locate xinetd
TIP 2. If you did not know this already, all of the web server html files for
Fedora are placed under: /var/www/html
The above command will give you a long list of processes with info beside
them like "off". Any process with the word "off" next to it can be assumed
disabled by default during startup. You should look for your processes that
are usually needed for running a webserver like httpd, telnet, wu-ftp,
mysqld. All of these should be "on" by default.
For your webserver and mysql, you can enable these things right away for
use during this session.
This directory (when listed) shows all processes you can start like httpd and
98
mysqld. For now let's start our web server with the command :
./httpd start
1. Edit the config files as applied to the "rc" directory of your choice.
Remember that all resource files activated at different run times are in
different rc.d directories. For instance, when your server is loaded at runtime
level 5 (usual) then all the resources under rc5.d are activated. Change
directory to:
/etc/rc.d/rc5.d
Remember that the rc5.d is a resource directory (under /etc) for run level 5...
etc.
You edit files in these directories to control what occurs at different run
levels. Files with a prefix of K are NOT installed to run at startup. Files with
S are ready to run at startup. Example names: K74ypserv or S14nfslock.
Summary for those needing one... You now should have your webserver
started and ready as default for all future starts with:
• ./httpd start
• mv k15httpd s15httpd
99
can not get telnet or ftp started. That's because they are not part of the
initd process, but rather the xinetd process. The xinetd process handles the
startup of all of your network related protocols etc.
Next type ls to list all of the processes that can be configured. You'll notice
for instance the file telnet.
2nd Edit the telnet file and change two lines:
# default: on
...
disabled = no
These lines are not adjacent, but usually the first and last lines of the
configuration file (in our case telnet). You need to edit all configuration
files that apply to things you're trying to start. Many processes come by
default turned off and disabled = yes. You can edit files like telnet, wu-ftp,
etc.
3rd Once you have edited and saved the files with the default on and
disabled = no, you can force an automatic restart of the xinetd to load
without rebooting:
/etc/rc.d/init.d/xinetd restart
Believe it or not, following all of this you should now have running:
• httpd (webserver)
• telnet
Now check to see what processes you have running again by using:
/sbin/chkconfig –list
or use the long "process" ps command like: ps -e | grep http.
You can use these same steps above to get mysql and ftp running. Replace
100
httpd with mysql, and telnet with wu-ftpd. Always remember there is a
difference between configuration and startup files under initd and xinetd.
Hopes this helps you get going! Special thanks to John for his inspiration
and to Tom for catching a typo that could have mislead readers!
All of these commands should work from your command prompt (regardless
which shell you're using). Just in case some folks were not aware, you
MUST press enter to invoke the command and the EX: stands for example
and is not part of the command. Commands are denoted in courier type font.
And of course, if they don't work or help you, we appologize!
101
Yep, you guessed it, typing logout will log your
account out of the system.
Type logout at the prompt to disconnect from your
Linux machine or to logout a particular user session
Use logout to quit from the system. Keep in mind that although
using the system rudimentary, leaving your critical account logged
on may be a security concern. We always
recommend promptly using logout when you are
finished using your root account! Ex:
logout
Type ls to see a list of the files and directories
located in the current directory. If you’re in the
directory named games and you type ls, a list will
appear that contains files in the games directory and
sub-directories in the games directory. Examples:
ls Mail
ls /usr/bin
Type ls -alt to see a list of all files (including .rc
files) and all directories located in the current
directory. The listing will include detailed, often
Use ls to list files and
useful information. Examples:
directories
ls -alt
ls -alt /usr/bin
If the screen flies by and you miss seeing a number
of files, try using the |more at the end like:
ls -alt |more
102
read the file’s contents. Why do we exmphasize
using this on a "text" file? Because most other types
contents of a file
of files will look like garbage! Ex:
more testfile.txt
Type passwd and press enter. You'll see the
message Changing password for yourname.
At the Old password: prompt, type in your old
password .
Then, at the Enter new password: prompt, type in
your new password .
The system double checks your new password.
Use passwd to change Beside the Verify: prompt, type the new password
your current password and press again.
103
handy when you forget which directory you’ve
changed to and are trying to run other commands.
Manipulating Files
You should see some files with the following in front of them
(an example follows):
total 4
drwxrwsr-x 7 reallyli reallyli 1024 Apr 6 14:30 .
drwxr-s--x 22 reallyli reallyli 1024 Mar 30 18:20 ..
d-wx-wx-wx 3 reallyli reallyli 1024 Apr 6 14:30 content
drwxr-xr-x 2 reallyli reallyli 1024 Mar 25 20:43 files
When listing your files, the first character lets you know
whether you’re looking at a file or a directory. It’s not part of
the security settings. The next three characters indicate Your
access restrictions. The next three indicate your group's
permissions, and finally other users' permissions.
104
very simple form this would be:
chmod 755 filename
The example above will grant you full rights, group rights to
execute and read, and all others access to execute the file.
# Permission
7 full
6 read and write
read and
5
execute
4 read only
write and
3
execute
2 write only
1 execute only
0 none
Still confused? Use the table above to define the settings for the
three "users." In the command, the first number refers to your
permissions, the second refers to group, and the third refers to
general users.
gives you full access, the group read and execute, and all others
execute only permission.
Ex:
cp newfile newerfile
To copy a file to a different directory (without changing th
e file’s name), specify the directory instead of the new
filename. Ex:
cp newfile testdir
To copy a file to a different directory and create a new file
105
name, you need to specify a directory/a new file name. Ex:
cp newfile testdir/newerfile
cp newfile ../newerfile
The .. represents one directory up in the hierarchy.
Ex:
file emergency3_demo.exe
This command allows you to figure out what the file type is and
how to use it. For instance the command will tell you whether it
is an executable, a compressed file and which type, or
something unusual.
Ex:
mv oldfile newfile
Ex:
rm newfile
Use the wildcard character to remove several files at once. Ex:
106
rm n*
This command removes all files beginning with n.
Type rm -i followed by a filename if you’d like to be prompted
before the file is actually removed. Ex:
rm -i newfile
rm -i n*
By using this option, you have a chance to verify the removal of
each file. The -i option is very handy when removing
a number of files using the wildcard character *.
107
Type mv followed by the current name of a directory and the
new name of the directory. Ex:
mv testdir newnamedir
Trying to find out where on your Linux server you currently are
located? The pwd (print working directory) command will show
pwd you the full path to the directory you are currently in. This is
very handy to use, especially when performing some of the
other commands on this page!
Options:
-s print the sum of bytes in your directories
-a print a line for each file in your directory
108
The grep command searches text files for a
particular word or string of words. Very helpful
when trying to find that needle in a haystack, like a
grep
particular line in a large log file.
syntax: grep textstring filename(s)
ex: grep century history.text.doc
head: prints the beginning of a text file
tail: prints the end of a text file
Head These commands allow you to view parts of a text
file.
Tail ex: tail -5 textfile.txt
The example above will print the last 5 lines of the
file textfile.txt.
Trying to find out where on your Linux server a
particular file resides? Having a real nasty time
doing it? If you have the Bash shell you can try
using the locate command to identify where it is on
your mounted drives.
locate
Type: locate filename and press enter. Replace
filename with the name of the file you are looking
for. This is a real time saving command as you start
navigating your Linux server!
If locate does not work for you try using which.
Nice: runs programs/commands at a lower system
priority
Nohup: runs nice programs even when you’re
logged off the system
Nice By using the two commands simultaneously, your
large processes can continue to run, even when you
Nohup have logged off the system and are relaxing.
Ex: nice nohup c program.c .
This command will allow the c compiler to compile
program.c even when you have logged off the
system.
ps The ps command displays all of the existing
processes. This command is also directly linked to
related to "stopped issues with stopped processes (also known as
jobs" "stopped jobs").
Occasionally, you may see the message There are
109
Stopped Jobs.
If you log off the system without properly stopping
your jobs, some jobs/processes may remain in
memory tying up the system and drawing
unnecessary processing bandwidth.
110
reach you.
You're bound to come across files that are g-zipped
and tarred. Okay, now what? These are methods of
compressing and storing directories and files in a
single "file." Most new Linux programs come off the
web as something like coolnew-game.4-4-01.gz.
This file is likely a tar file that has then been gzipped
for compression. The way to handle these files is
simple, but requires that you put the file into an
tar appropriate directory. In other words, don't plop the
file in your root or /bin unless it belongs there.
also related to gzip
Now you can do a one fell swoop un-gzip it and
untar it into its original form (usually multiple files
in many sub directories) by typing: tar -xvzf *.gz
111
followed by the command ftp. In order to re-display
the clear command you type: !cl and press enter. In
order to re-display the last command you typed,
simply type: !! . Try it out. You’ll find this a time
saver when dealing with long commands. Especially
commands like tar!
112
Assignment No: 13
Theory:
Please refer the separate manual on LAN Explorer & ETHREAL software.
113
Assignment No: 14
Objective: Study of existing LAN and understand the design and various
components. Set up a small network of 3 to 4 computers and Hub/Switch as
directed by the instructor. Use LAN Card, UTP Cables and Connectors.
Install LAN Cards and Crimp the connectors. Assign unique IP addresses
and share C drive on each machine. Test the network by using PING
command. Use protocol analyzer Software.
Theory:
114
Assignment No: 15
Theory:
Preface:
Earlier, I showed you how to add users to your Active Directory domain.
This tutorial will focus on how to add computers. This step is not "really"
necessary for workstation computers - at least, I was able to add a Windows
XP machine to my domain without adding the computer name first. This is
section is really for looking at which computers join, and allow other servers
to join as DC's, etc. I will show you how to add the computer using "Active
Directory Users and Computers", then in other tutorials, I will demonstrate
how to add a Windows 2000 computer and Windows XP computer to this
domain.
Update:
115
Brian Desmond (Windows Server MVP) emailed me with the following
information on why someone might want to add a computer to AD
manually:
"By default a computer will get dumped in the Computers container, unless
a Windows 2003 Native Mode Domain is inplace, and redircomp has been
run to change this. Precreating computer accounts in OUs will ensure that
when the unit is joined, it is in the correct OU, which guarantees policy
consistency, and other administrative things. One can also specify who can
reset the machine’s password. This will allow an admin to create an account
for a computer, and let a normal user join the machine with their
credentials."
Method:
3.In this dialog we have to type the name of the computer we want to add
4 In the next dialog just click "Next", then you will see a final report of what
will be added, and you can click "Finish".
Method:
2. Now, expand your domain name on the left side, and go to the bottom
where it says "Users". Once you click on that, you will see all of the
automatically created users, you will also see all of the users you made
before you ran dcpromo - that's because they all stay through the promotion
to DC. Anyway, to add a user, you can either right click the "Users" folder
on the left side, or the blank area on the right side, and highlight "New" then
click "User"
116
3. In the next dialog we can set the user's First name, Last name and various
other pieces of information, including their log-on name, and domain to
which we want to add them.
5.In the next dialog, we get a summary of the user to be created. Click
"Finish" and the user has been created
6. And we're finished! Now, you might want to check out the tutorial on
how to add a computer to Active Directory, that will help you get the full
benefits of AD.
APPLICATIONS:
FAQS
117