Sunday, 10 August 2014

C Programming for Beginners - 1 | C Language Tutorial for Beginners

C Programming for Beginners - 1 | C Language Tutorial for Beginners https://www.youtube.com/watch?v=qlp8_zlMnSk ...

Robert Sebesta Web technology text book

https://www.dropbox.com/s/n68k0y135s86e0o/Programming%20the%20World-Wide%20Web-Sebesta%20Robert.r...

Write an awk script to compute gross salary of an employee accordingly to rule given below. If basic salary is < 10000 then HRA=15% of basic & DA=45% of basic. If basic salary is >=10000 then HRA=20% of basic & DA=50% of basic.

BEGIN{ printf"enter the basic salary:Rs" getline bp<"/dev/tty" if(bp<10000) { hra=.15*bp da=.45*bp } else { hra=.2*bp da=.5*bp } gs=bp+hra+da printf"gross salary=Rs.%.2f\n",gs }&nbs...

Write an awk script to find out total number of books sold in each discipline as well as total book sold using associate array down table as given below. Electrical 34 Mechanical-1 67 Electrical-1 80 Computer Science 43 Mechanical 65 Civil-1 198 Civil 198 Computer Science-1 64

BEGIN{ printf "enter the mechanical books:" getline mc <"/dev/tty" printf "enter the electrical books:" getline ec <"/dev/tty" printf "enter the computer books:" getline cs <"/dev/tty" printf "enter the civil books:" getline ci <"/dev/tty" } { if(NR==1) tot1=$2-mc if(NR==2) tot2=$2-ec if(NR==3) tot3=$2-cs if(NR==4) tot4=$2-ci } { if(NR==4) { printf "total mechanical books present:%d\n",tot1 printf "total electrical books present:%d\n",tot2 printf "total computer books present:%d\n",tot3 printf "total civil books present:%d\n",tot4 }...

Write an awk script to delete duplicated line from a text file. The order of the original Lines must remain unchanged.

BEGIN {i=1} { flag=1; for(j=1;j<i && flag ; j++) { if(x[j]==$0) flag=0; } if (flag) { x[j]=$0; printf("\n%s",x[i]); i++; }...

Write an awk script that accepts date argument in the form of mm-dd-yy and displays it in the form if day, month, and year. The script should check the validity of the argument and in the case of error, display a suitable message.

BEGIN { FS="-" f=1; printf("enter date with (mm-dd-yy) format:"); getline < "/dev/tty" if(((($3%4!=0) && ($1==2) && ($2>28)) || (($3%4==0) && ($1==2) && ($2>29))) || ((($1==1) || ($1==3) || ($1==5) || ($1==7) || ($1==8) || ($1==10) || ($1==12)) && ($2>31)) || ((($1==4) || ($1==6) || ($1==9) || ($1==11)) && ($2>30)) || ($1<1) || ($2<1) || ($3<1) || ($1>12)) f=0; if(f==0) printf("you have entered an invalid date\n"); else printf("\n \tThe date= %d\nThe month=%d\nThe year is=%d\n is valid date\n",$2,$1,$3);...

Write a shell script that accept the file name, starting and ending line number as an argument and display all the lines between the given line number.

if [ $# -ne 3 ] then echo "Pass minimum three arguments" exit fi c=`cat $1 | wc -l` if [ $2 -le 0 -o $3 -le 0 -o $2 -gt $3 -o $3 -gt $c ] then echo "Invaid Input" exit fi sed -n "$2,$3p" ...

Write a shell script that accepts two integers as its argument and compute the value of first number raised to the power of second number.

if [ $# -ne 2 ] then echo "Invalid number of arguments" exit fi pwr=`echo $1^$2 |bc` echo "$1 raised to $2 is : $pw...

Write a shell script that reports the logging in of a specified user within one minute after he/she log in. The script automatically terminate if specified user does not log in during a specified period of time.

a=`date +%M` b=`expr $a + 1` while [ $b -gt `date +%M` ] do who | grep $1 if [ $? -eq 0 ] then echo "$1 has logged in 1 minute" exit fi done echo "$1 has not looged in within 1 minut...

Write a shell script that determine the period for which a specified user is working on system.

echo -e "enter the user name :\c" read usr tuser=`who | tr -s " " | head -1 | cut -d " " -f1` if [ "$tuser" = "$usr" ] then tm=`who | tr -s " " | head -1 | cut -d " " -f4` uhr=`echo $tm | cut -d ":" -f1` umin=`echo $tm | cut -d ":" -f2` shr=`date "+%H"` smin=`date "+%M"` if [ $smin -lt $umin ] then shr=`expr $shr - 1` smin=`expr $smin + 60` fi h=`expr $shr - $uhr` m=`expr $smin - $umin` echo "user name : $usr" echo "login period : $h : $m" else echo "Invalid User" ...

Write a shell script that accept a list of filenames as its argument, count and report occurrence of each word that is present in the first argument file on other argument files.

if [ $# -ne 2 ] then echo "Error :invalid no of arguments " exit fi str=`cat $1 | tr '\n' ' '` for a in $str do echo "word=$a , count=`grep -c "$a" $2` " do...

Write a shell script that gets executed displays the message either “Good Morning” or “Good Afternoon” or “Good Evening” depending upon time at which the user logs in.

echo "Greetings of the day" echo `date` h=`date |cut -c 12-13` if [ $h -ge 0 -a $h -lt 12 ] then echo "Good Morning" elif [ $h -ge 12 -a $h -lt 18 ] then echo "Good Afternoon" elif [ $h -ge 18 -a $h -lt 20 ] then echo "Good Evening" else echo "Good Night" ...

Write a shell script that delete all lines containing a specific word in one or more file supplied as argument to it.

if [ $# -eq 0 ] then echo "Please enter one or more filenames as argument" exit fi echo "Enter the word to be searched in files" read word for file in $* do sed "/$word/d" $file | tee tmp mv tmp $file do...

Write a shell script that compute gross salary of an employee, accordingly to rule given below.

If basic salary is < 15000 then HRA=10% of basic 7 DA=90% of basic. If basic salary is >=15000 then HRA=500 of basic & DA=98% of basic. Echo ―enter Basic salary‖ read basic if [ $basic -lt 15000 ] then hra=`expr 10 \* $basic / 100` da=`expr 90 \* $basic / 100` else hra=`expr 50 \* $basic / 100` da=`expr 98 \* $basic / 100` fi gs=`expr $basic + $hra + $da` echo "Gross salary : Rs. $g...

Write a shell script to compute the sum of number passed to it as argument on command line and display the result.

sum=0 for i in $* do sum=`expr $sum + $i` done echo "Sum of Number is : $su...

Write a shell script using expr command to read in a string and display a suitable message if it does not have at least 10 characters.

echo "Enter a String" read str c=`expr "$str" : '.*'` if [ $c -lt 10 ] then echo "The String has Less than 10 charecter" else echo "The String has $c charecters" ...

Write a shell script to find smallest of three numbers that are read from keyboard. echo "Enter the Three Numbers"

read a b c if [ $a -le $b -a $a -le $c ] then echo "$a is Smallest" elif [ $b -le $c -a $b -le $a ] then echo "$b is Smallest" else echo "$c is Smallest" fi&nbs...

Write a shell script to display the calendar for current month with current date replaced by * or ** depending on whether the date has one digit or two digits.

set `date` y=$3 if [ $y -le 9 ] then cal |sed "s/$3/*/" else cal |sed "s/$3/**/" ...

Write a shell script that accepts as filename as argument and display its creation time if file exist and if it does not send output error message

. if [ $# -eq 0 ] then echo "No argument" exit fi if [ -f $1 ] then time=`ls -l $1|cut -c 33-59` echo "File $1 has created on $time" else echo "File $1 does not exist" ...

Write a shell script that accept one or more filenames as argument and convert all of them to uppercase, provided they exist in current directory.

for f in $* do if [ -e $f ] then cat $f|tr "[a-z]" "[A-Z]">tmp mv tmp $f else echo "File $f does not exist" fi do...

Create a script file called file-properties that reads a file name entered and outputs it properties.

echo "Enter a file name" read file if [ -f $file ] then set - -`ls -l $file` echo "file permission : $1" echo "number of links : $2" echo "User name : $3" echo "Owner name : $4" echo "Block size : $5" echo "Date of modification : $6 : $7" echo "Time of modification : $8" echo "Name of file : $9" else echo "File does not exist" fi&nbs...

Write shell script to implement terminal locking (similar to the lock command). It should prompt the user for a password. After accepting the password entered by the user, it must prompt again for the matching password as confirmation and if match occurs, it must lock the keyword until a matching password is entered again by the user, Note that the script must be written to disregard BREAK, control-D. No time limit need be implemented for the lock duration.

stty –echo while true do clear echo "Enter the paasword" read pass1 echo "Re enter the password" read pass2 if [ $pass1 = $pass2 ] then echo "Terminal locked" echo "To unlock enter the password" pass1="" until [ "$pass1" = "$pass2" ] do read pass1 done echo "Terminal unlocked" stty echo exit else echo "Password mismatch retype it" fi do...

Write a shell script which accepts valid log-in names as arguments and prints their corresponding home directories, if no arguments are specified, print a suitable error message.

Clear if [ $# -eq 0 ] then echo "No command line argument passed" exit fi while [ $1 ] do cat /etc/passwd | cut -d ":" -f1 | grep "^$1" > temp ck=`cat temp` if [ "$ck" != "$1" ] then echo "ERROR:$1 is an invalid login name" else echo "Home Directory for $1 is" echo `cat /etc/passwd | grep "^$1" | cut -d ":" -f6` fi shift do...

Write a shell script that takes a valid directory name as an argument and recursively descend all the subdirectories, finds the maximum length of any file in that hierarchy and writes this maximum value to the standard output.

if [ $# -ne 1 ] then echo "No argument" exit fi if [ ! -e $1 ] then echo "The given directory does not exist" exit fi echo "The file with maximum length $1 dir is" ls -lR $1|tr -s " "|cut -d " " -f 5,10|sort -n|tail -n...

Write a shell script that accepts two file names as arguments, checks if the permissions for these files are identical and if the permissions are identical, output common permissions and otherwise output each file name followed by its permissions.

if [ $# -ne 2 ] then echo "No arguments" elif [ ! -e $1 -o ! -e $2 ] then echo "FIle does not exist" else p1=`ls -l $1|cut -c2-10` p2=`ls -l $2|cut -c2-10` if [ $p1 == $p2 ] then echo "File permissions are equal & is $p1" else echo "File permissions are not equal" echo "1st file $p1" echo "2nd file $p2" fi ...

Tuesday, 29 July 2014

USEFUL LINKS

1. elearning.vtu.ac.in/ 2. Coursera 3. Slide Share 4. IndiaBix.com 5. studyittoday.blogspot.com  ...

DBMS Lab5 [MySQL]

v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0 false false false false EN-IN X-NONE X-NONE ...

 
- |