Thursday, September 27, 2007

DCN386 Great Site For Test 1

Practical Guides . . .
Practical Guide to Analog Modems
Practical Guide to Frame Relay
Practical Guide to 56k
Practical Guide to Binary, Decimal and Hexadecimal Numbers

OPS435W4L1

OPS435W4

Assignment #1 is up and running, what we need to do , last couple of weeks if we get a birthday date you can get the month year date out to do calculations and that’s all the assignment is about, write a script any user can run your script in two different ways, you create a file called age.bash and the user can provide you with your data in two different ways, one they put it on the command line as an argument, age.bash 19850330, or they can do it this way age.bash and no arguments, so in the first instance they are providing the data from the command line and the second they are not, there for the script must check to see if the user provided you with the data/argument, if they didn’t provide you the data you ask for it command to use to ask
Echo “YOUR DATA HERE”
Special command you use to capture data from the key board and that command is the

READ variable

So the variable name what ever name you assign to it that data will be automatically assigned to that variable, couple of examples later,

…once you have the data, and this applies to every program you write when communicating with users anytime you get data from the user you never use that data immediately you must verify it, if you try to use incorrect data you script will fail, FIRST VARIFY the data, once you ascertain the data is correct then you start using it not before, so we will see how you do this, your script for instance in two stages 1 and 2 the first stage and the submissions dates are different, stage 1 2 weeks stage 2 4 weeks, stage 1 verification of the data, first the we see the final result that should be displayed on the screen, all this is for stage two…..LETS LOOK AT STAGE 1

There are 5 steps you must go through
Step 1
The date is number 1

Determine they gave the data or not, if they have then you have the data if they did not provide you with the data on the command line then it is captured in the variable now you got to verify the data,

Step 2
Look at the data how long is it….is it 8 characters…….${} -this construct
If the eight chars are not their you got to tell
Then determine if their all numbers
Then check if the date is valid
We have to see through the cal date if its valid

Display feb 1989
U tell them what you entered and tell them its an invalid date, if the date it valid then you go check the last item to future date, you can have a user that hasn’t been born yet, if it is correct you have verified the data coming then parse it and do it for stage two

Lets see methods on how to do this, stage 1 should be inside a loop, if its incorrect you have to go back to top and verify from the begging stage one should be inside a loop data provided should be correct to get outtake the loop, for you u don’t have to have it on a loop. For our submission it’s a one shop deal, how do you know if they entered data on the command line…well you don’t yet so this is how its down.

Lecture Schedule Slides:
#! shbang
#  comment

Understanding parameters when you enter anything on the command line the shell captures everything that’s their, its captured, lets say we run are script and we have multiple arguments lets say

A b c d e ………… j k l

The moment you hit the return key the shell captures everything on the command line….special variables called predefined special variable…..what they are is this the command is age.bash it will automatically be assigned to a special variable called 0, remember variables and what chars you can use to assign names to

Variables = letters, underscore, numbers as long as their not in the first

If you want to see what is the name of the program what command will you use….

echo $0 it will automatically tell you the name of the programs, if you say

echo $1 the first arguments and so on

$10 and up don’t exist , some of the new shells can go beyond but not all

Beside $0-9 the rest of var

$@ expands into all the arguments ( abcde…..) (puts “ “)
$* same thing as all ( this doesn’t put “ “)
$# it will tell you how many arguments were entered in the command line
$? The exit status of the last command executed
$$ PID of the currect running shell
Ex: ls A? && echo banana
Goes into $? If it = 0 then its successful, and if its not 0 then its failed

$! PID of the last command executed in the background


These are the parameters need to know the love, and $0-9

The read command and how it works,

Read a
Sits and waits for it

Echo $a will show you what was entered

Read a b
Reads the first word then the last one captures the rest

You can use the read command for everything

Read –p print the text on the screen more then one word put it in quotes…..

Read –p “give me your birthday” a b d

Read –s silent….it doesn’t show on the screen you use for passwords

This is how you capture data from a user from the keyboard using the read command.

Readonly makes it so you can change the value of the variable………………….

Now the

If
then
else

the if statements executes the command what ever u place after the if statement, when it executes the command it goes to $? To see if the command is successful or not and if its successful it will go to the then or it will go to the else, fi  like end if. Simplest version if
If
Then
Fi

One command under command , else is optional.

Vi ass1

With the test command you can do checking of variable,
Test value1 value2

test $# != 0

if and a read command to see if it equals to zero.

Or you can do bd=$1 which will give you what was read from the command line, after the if statement echo the variable, run the program or script and see what happens

#!/bin/bash < tells the program where its run from shbang
You can use the test command under two different ments
[ $# = 0 ] ( testing the number of arguments equalling to zero ) && echo you did not enter any arguments on the command line && exit

Since we have entered four it will go to the next command the
More arg  display the contents of the script

When you run g a program the sub-shell will run your program, so when you did echo $$ in your script you showed the PID of the shell running your script.

Echo –e – interrupts backslash characters, the UNIX command uses \ to tell what to do the Linux version of echo does not recognize \ chars

Echo –n do not echo the new line character if you don’t wanna go to the next line this is linux, unix does it this way echo \c

-e linux command recognise the back slash characters then you can use \n to say enter a new line

While loop, simply how they work, just like the if statement if followed by command while followed by a command and the while statement will check the $? Of that command to see if its successful or not, and if it successful it will execute between the do and the done, and from the done it will go back to the while, if it is it will go through the loop again

Is 11 not equal to 44

[ $1 –ne 44 ]

SHIFT – how it works, will shift the arguments the variable $1 through $9 once to the left, what will happened $2 into $1 the contents of $1 goes into the garbage bin its gone, what happens if we did
Shift 2 ---- shift twice to the left,

Find the programs in public, programs are arg and args

Echo –n new line take out
Or construct with the braces try and use that one


BREAK

Command we already know the
Grep command use a number of different options,

Grep pattern data

We will look at regular expression do the same thing for data rather then file names , similar chars with meanings, the grep command is the one that interprets the regular expression, it’s the command itself that does the interpretation of regular expression, when your using a pattern use a ‘ ‘ if you don’t have a special char the ‘’ are doing nothing the ‘’ tell the shell don’t touch this pass it on the command to interpret, if you had a char in their this is not a special char.

Grep searching for a pattern in a database and when it finds it what does it do, it displays the whole line you found the match in

Cal 05 1887|grep F

Number of options with this command, how do you display only the line that has 2 as a full word and not part of a pattern?

Cal 05 1887|grep –w 1

-w word only
-i ignore case
-q quiet
-E
grep and xtended grep, it can use regular exp and also you xtended reg xpression, regular grep search for one patter, x multi patters, if you wanted to use xtended grep egrep or grep –E

-c count of number of lines matched
-v all lines that do not match the patte

Tuesday, September 25, 2007

DAT702 W4L1

DAT702


create table marvin select * from grades;
copies new table, does not copy constraint
create table marcin2 select grades,stunum,code
create table marvin3 select * from grades where 1 = 1
create marvin three and get the same thing where this is very usefull as we create marvin4
1= 21 this will copy an empty table, but its the same table.

“We just did table copy” ExamHint -table alias will be important

Select What about the repeated names” AnotherExamHint


In lab 3 like a list of the same students as the first name of all the other students were lookinga the students that have the same first name as the other students, think of ur students table, somewhere you have mary and another mary somewhere else at the table, databases process one record at a time, how will it process those two, we are going to deal with this but dealing with one table it will not work, the way we do this, back to the things we talk about before,

Select * from students,students; < Cartesian product when no where clause,

If the students table at 40 record cheat give table alias
Select * from students s1,students s2; < Cartesian product

We are going to only show certain things

Select s1.firstname,s1.lastname,s2.firstname,s2.lastname from students s1.students s2 where s1.firstname = s2.firstname and s1.stunum <> s2.stunum;


Select distinct s1.firstname,s1,lastname,s2.firstname,s2.lastname from students s1.students s2 where s1.firstname = s2.firstname and s1.stunum <> s2.stunum order by s1.firstname;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Needed

Select “Another example of a join” AnotherHInt;

Select * from grades where code = “hwd101”:

Select stunum. From grades where code = “hwd101”;

Select * from grades g1,grades g2 where g1.code = “hwd101” and g2.code = “ops200”;

Select distinct g1.stunum from grades g1,grades g2 where g1.code = “hwd101” and g2.code = “ops200”;


Select “ Now the easy way” ExamHint;

Select * from student innter join grades on students.stunum = grades.stunum;

If we rewrite and put left join it will show a bunch of people with null

Inner join takes students and student number , left joins is finding the Nulls, if we want to make it nicer you isolate the nulls and do a where clause


Where Grades.code is null


Select “Now the other way” examexam;

Select stunum from grades; 1 column 1 field, every one took a course, its one field,

Select * from students where stunum not in (select stunum from grades);
All people that didn’t take the course, called a sub query

Select * code from grades where stunum in (Select max(grade)from grades where code = “HWD101” and grade in (select max(grade) from grades where code = “hwd101”));

In brackeys sub query, back to front

Select max(grade)from grades where code = “HWD101” and grade in (select max(grade) from grades where code = “hwd101”);


Select students.* from students, grades
Where students.stunum = grades.stunum and grades.code in
(select code from grades where stunum in
(select stunum from grades where code = “hwd101” and grade in
(select max(grades) from grades where code = “hwd101”)));

^^^^end of sql this end of mysql, writing queries, in most term test do something with a left join and a sub query, run a practical test on Thursday,

Want to know everybody who taken ops400 and hwd101

Select stunum from grades where code = “ops400” and stunum in
(Select stunum from grades where code = “HWD101”);

^^^^^^runs is twice did a sub query that took one of courses, runs it again finds the ops400 now it knows each one of those took ops400 and 101

Select * from students where stunum in
(Select stunum from grades where code = “ops400” and stunum in
(Select stunum from grades where code = “HWD101”));

^^^^^^^^^^Shows the whole table

Practical test based on lab four

OPS335 W4L1

OPS335 FREEEEEE^^^^^^^^^^^^^^^^^^^^^


Confusing about the hard drive layout, if he shows us pictures of sector 0 which is the first sector on the drive, sector 0 is going to be the MBR, after that you have the first partition so you have partition number 1 it’s a whole bunch of sectors it be at least one cylinder well the first partition is the 1st sector of the 1st partition, so if he said for example, lets say sda if he says dd if=sda then sda is going to be the mbr if sda1, then you will be getting the 1st sector of the 1st partition, and pretend we have portions number 2 this is the first sector of the second partition, so sda2 then your copying another sector and not the 1, the MBR is bootable that’s when you do the file command it’s a bootable file, the other sda1 and sda2 are not bootable cause they are second in command, but always the mbr is first if you file one of mbr it will just say data. Mymbr 512 bytes

Df look at whats on ram
Fdisk –l look hat the partitions

Ls / is the ram only system

Mount /dev/sda2 /mnt

Find /john –name menu.lst

Updatedb – updates whole database

So we went over how linx boots

POST
BIOS –activates code, program comes with the main board. Grabs MBR
MBR – LILO or GRUB NTLDR any loader you want then executes in memory reads the Kernel and initial ram disk

Initial ram disk file holds drivers that the kernels needs to mount the fs
Kernel – probes all your hardware, on your main board there are hardware ports for many different busses, each port has an address and all the kernel does when its booting up it sends a messages to all the buses then all the ports on the busses, asking is their anything their, 18 PCI if theirs nothing their in micro second the kernel says theirs nothing their, if it sends to you network card it will send a string back, the name of the piece of hardware, network card made by intel…..

Then is mounts the root file system then it mounts it then inside the root file system it finds the init program and init looks inside /etc/inittab, and from here it knows the run level…7 diff run levels after init it calls rc, small name for a important programs now that is knows the run level it will go to directory that is called rc3.d it will go into that directory and all of the scripts that start with a capital s will run them in numerical order, each one represents a sub-system …a start up of a sub-system.

When you see fedora or suse then it says done every of the green lines is one script finished it’s the script that writes that line out that means its done. FAILED, STARTED, u know which is working or not, …


Run level 3, its multi-user with network, run level three ill let everyone log ssh, ftp. In the dir /etc/init.d this is the scripts of all the sub-systems in the computer, if you did not install sh server the script would not be their. The important thing to note the scripts are used for start up and for shutdown, if you want to start up the sshd server you use the same scripts, how does it know what to do by the link name capital S or K, when it calls the script and it begines with a S its starting and with a K shutting down, so where are these scripts > rc3.d their all links some are capital S and some capital K and each are al ink to the other scripts ls –l S09sshd it linked to sshd this is the start up script to start the SSH server,

Run level 5 graphics multi-user network

Ps ax | grep sshd

What ever service ur running u will have the actual program and also a start up and shutdown script,

Carpald – server
Carpal – start and shut down script


telnet 3 drops you to run level three, it will run all the shutdown scripts for 5 and start up for 3, better then doing a reboot,

wall write to call
ln – link
chkconfig

init telinit
ls is a user process
how is a daemon different

Phase synchronization

Phase synchronization is the process by which two or more cyclic signals tend to oscillate with a repeating sequence of relative phase angles.

Phase synchronisation is usually applied to two waveforms of the same frequency with identical phase angles with each cycle. However it can be applied if there is an integer relationship of frequency, such that the cyclic signals share a repeating sequence of phase angles over consecutive cycles. These integer relationships are the so called Arnold Tongues which follow from bifurcation of the circle map.

One example of phase synchronization of multiple oscillators can be seen in the behavior of Southeast Asian fireflies. At dusk, the flies begin to flash periodically with random phases and a gaussian distribution of native frequencies. As night falls, the flies, sensitive to one another's behavior, begin to synchronize their flashing. After some time all the fireflies within a given tree (or even larger area) will begin to flash simultaneously in a burst.

Thinking of the fireflies as biological oscillators, we can define the phase to be 0° during the flash and +-180° exactly halfway until the next flash. Thus, when they begin to flash in unison, they synchronize in phase.

http://en.wikipedia.org/wiki/Phase_synchronization

Sunday, September 23, 2007

Acoustic Coupler......way back...Half/Full Duplex DCN386

Personal fav….pin 22, think about a computer using a modem to contact another modem, how does a computer working with a modem know how to make a phone call, essentially this I what you do make a phone call to send data, …reminisce BNS got this new tech, mainframe comp and they had a telephone and fit into a device attached to a computer, u pick up the phone and heard this noise and put it to the ……acoustic coupler, a company called haze who made acoustic couplers, though themselves why not put a computer chip that can recognize basic basic commands… and they did, they invented the modern modem, 70% of people today, they will discover two things they are using RS-232 they are using Haze Compatible instructions<-- all the rage, haze instructions all start with AT what happens OS software in ur computer understands haze commands if you try to call someone it will send a attention command to ur modem, you want to modem to dial

AT [D]pulse1231321

Something called tone dialling and pulse dialling, lets say u wants pulse the os in the software in the old days you had to install the isp number the modem will recognize the above and the modem will send out a ringing sound to the DCE and the dce hears the ring ring sounds the modem has to ask the computer if its ok to answer the sound, the modem actually asked if it was ok to answer an incoming call, it will do so through
PIN22 ring control

It will signal down DTR, and it will know to answer the phone, if you were an isp then you would be great cause you want to answer incoming calls as fast as possible cause the isp always wanted auto answer, some modem automatically answer ATA

How many functions do we got,
that the half duplex, for the 70% people of the world still using modems its no longer half duplex, no phone company offers half duplex any more everything is full-duplex, what is full-duplex, send and receive at the same time.

Theirs is flow control one of the great instincts of control data is getting to the destination with out loosing data and getting their error free

Any activity that prevents the loss of data ----FLOW CONTROL


Look at this your ISP is sending stuff to you stuff is going to the modem, the way file transer programs work, data set through the serial port and they are stored in memory the os knows that the computer memory is getting used up sooner or later, pretend you want to download a file and write to ur floppy disk…floppies are slow…sooner or later the memory is getting used up and needs to write to disk, what happens to incoming data, it could get lost Rs-232….Request to send and Control send to flow control the data, if the computer knows not to send data it will stop sending pulses request send, the modem now goes it will not send data and will send signals the other modems to stop sending data, now that the floppy writing has finished it will then tell its okay to send, if the modem detects the line is busy it can send signals using clear to send, ……request send clear to send is used to flow control purpose/--this is what we have to tell him

Look on the internet RS-232 despite the fact is has their RS-232 Tutorial, no more physical layer stuff …Analog and Digital physical layer considerations Multiplex Interfaces physical layer…..start talking about protocols….cause we love protocols



First protocol we are going to talk about IP we will talk about IP next Friday, what we are talking about now is our first opportunity to get some marks, which will be next week, at least three marks, three percent of the course marks can be gained next week if you can go to back it has two configurations

R1 has a config
R2 has a config

You simplay type in the config for both routers hook the routers up rogether using serial cables S1 S0 hand also hook up a work station to the Ethernet port of the routers if he can ping form one to the other your up three percent.

What you do when your doing a config, you provide an ip addresss to that serial interfaces you provide the ip address to both Ethernet ports, what is an IP address,

Where do they com from, IP 4 bits long , they have to be unique, there are different classes, and the ip address is two address one the network and the other part identifies the computer on that network. Theirs millions of networks in the world, Seneca college has dozens of networks. Each network has a network identifier and a component that identifies the computer in the network

What are the class? Why were the classes developed, it was an accident, back in the beginning of the internet when their was a few organizations using this, if you examine the fundamental protocols the internet uses, its actually tremendously inefficient, the guys who invented ip were computer programmers they decided arbitrarily to have a 4 byte address, they decided to use the 1st byte to be a network identifier because about a dozen people on the network, they reserved these bits, the other were all host bits, on individual networks, Network one would be 0000001, 00000010, 4 the internet grew, 256 networks, they sat down and said lets change this lets make the old way class way, but have a new scheme have a range of addresses, and make B

0-127 A

B 1000000 - 128
1011111 – 191
Host 64 k

IEEE class C
1100000 - 192
1101111 – 223\


255-32


Static ip in the work station


Subnetting, why do we have subnets?