Thursday, February 20, 2020

Ring Central - Game Changer

In today's smart phone world everyone trying to reach their customers ASAP.
The Ring central Game changer offers an excellent platform to communicate with SMS, CALL, ..etc


please refer following to know more about API

https://developers.ringcentral.com


Wednesday, July 17, 2013

Unix commands

UniX Exercise 1



  1. Write a command to print the ouput “Today is Tuesday, 5th day of month, year”.
Sol.            date +”Today is %a, %d of %b, %Y”

  1. Assume that files in a directory are “filename_dd_mm_yy”, write a command to list the files created today.
Sol.            ls *_`date +”%d_%m_%y”`

  1. Write a command to copy a file x to y using cat.
Sol.            cat x > y

  1. Write a command to copy the contents of 2 files into a third file.
Sol.            cat x y > z

  1. Write a command to copy the contents of x, user input, y into a file.
Sol.            cat x - y > z

  1. Write a command to copy the contents of x and y prefixing the file name before starting file contents.
Sol.            ls x > z; cat x >> z; ls y >> z; cat y >> z

                                          (Or)

                  (ls x; cat x; ls y; cat  y) > z

  1. Write a command to generate the following into a file
Files of the directory on

           

Total files in the directory are
Sol.            (echo –e “Files of the directory `pwd` on `date +%D`\n\n”;
 ls -l;echo –e “\n\n Total files in the directory are `ls –l | wc –l`”) > z

  1. Assume package name of each java program is in line 1, write a command to display all package names.
Sol.            head -1 *.java

  1. Write a command to display top 3 files which were created recently.
Sol.            ls -ltr | head -4 | tail -3

                                          (Or)

ls -ltr | tail +2 | head -3

  1. Write a command to display lines 23 to 44 of file y.
Sol.            head -44 y | tail +23
  1. Write a command to count number of words in last but one line of file y.
Sol.            tail -2 y | head -1 | wc -w

  1. Write a command to display 15th line of every file in the current dir.
Sol.            cannot be solved with commands need to write shell script.

  1. Write a command to display the total number of bytes used by all files of the current directory.
Sol.            wc –c * | tail -1

                              (or)
                 
                  cat * | wc -c
     
  1. Write a command to copy file x to y only if y not exits.
Sol             ls y || cp x y

  1. Write a command to convert all characters of file x to capitals.
Sol             cat x | tr “a-z” “A-Z”

                              (or)
                 
                  tr “a-z” “A-Z” < x

  1. Write a command to count number of spaces in line 15 of file x.
Sol             head -15 x | tail -1 | tr –cd “ “ | wc -c

  1. Write a command to convert all tabs to spaces of a file.
Sol             cat x | tr “\t” “ “

  1. Write a command to join all lines of a file.
Sol             cat x | tr “\n” “ “

  1. Write a command to join lines 15 & 24 of a file.
Sol             (head -15 x | tail -1; head -24 x | tail -1) | tr “\n” “ “

(or)
                  echo ‘head -15 x | tail -1` `head -24 x | tail -1`


  1. Write a command to display machine hardware type.
Sol             uname –a | cut –d” “ –f6

  1. Write a command to display file permissions and filename.
Sol             ls -l | tr -s " " | cut -d" " -f1,9

  1. Write a command to display the file mask applied for file owner.
Sol             umask | cut –c 1

  1. Write a command to display empno, empname and sal from emp.db.
Sol             cut -d"|" -f1-2,6 emp.db

  1. Write a command to display the total time taken for the above query.
Sol             time cut -d"|" -f1-2,6 emp.db | tail -3 | head -1

  1. Write a command to calculate total amount used by company as salaries.
Sol             echo `cut -d"|" -f6 emp.db | tail +3 | tr "\n" "+"` 0 | bc

  1. Write a command to calculate total amount used by company as salaries along with the message “Total Salary of all employees is : ”.
Sol             echo -e "Total salary of all employess is  : \c";
echo `cut -d"|" -f6 emp.db | tail +3 | tr "\n" "+"` 0 | bc

  1. Write a command to count number of employees in department 10.
Sol             cut -d"|" -f8 emp.db | grep -wc 10

  1. Write a command to list all employees in the department in which SMITH is working.
Sol             cut -d"|" -f2,8 emp.db  | \grep -w `cut -d"|" -f2,8 emp.db  |
grep -w SMITH | cut -d"|" -f2

Hibernate tutorial

Hibernate Tutorial
Bash Shell Script

write a c shell script that takes an integer number from the keyboard and displays the fibonacci numbners equal to the number entered from the keyboard. thus if the user enters 7, your script displays the first seven fibonacci numbers

#!/bin/bash
#####################################################
# File Name: sy_4_g
#
# Usage: ./sy_4_g
#
# Author: Suresh Yadagiri
# Date:  August 06,2010
#
# Requirements:
#     write a c shell script that takes an integer number
#     from the keyboard and displays the fibonacci numbners
#     equal to the number entered from the keyboard.
#     thus if the user enters 7, your script displays the
#     first seven fibonacci numbers
#
#
#####################################################

function printusageinfo(){
echo -e "\nUsage: $0 \n"
}

function is_integer() {
    printf "%d" $1 > /dev/null 2>&1
    return $?
}

if [ $# -eq 0 ]
then
        echo "At least one argument expected"
        printusageinfo
        exit 1
fi

if [ $# -gt 1 ]
then
        echo "Too many arguments"
        printusageinfo
        exit 1
fi

if ! is_integer $1;
then
        echo "Integer argument expected"
        printusageinfo
        exit 1
fi

if [ $1 -lt 2 ]
then
        echo "invalid arguments.enter greater value"
        printusageinfo
        exit 1
fi

echo "The first $1 fibonacci numbers are"
counter=2
n1=0
n2=1
echo $n1
echo $n2
until [ $counter -eq $1 ]
do
  current=`expr $n1 + $n2`
  echo $current
  counter=`expr $counter + 1`
  n1=$n2
  n2=$current
done
exit 0

This script takes integer numbers as command line arguments and displays their sum on the screen if run with no arguments, it informs user with usage message

#!/bin/bash
#######################################################
# File Name     :    sy_3_g
# Author:    :    Suresh Yadagiri
# Date        :    July 27,2010
# Descriptiom    :   
#  This script takes integer numbers as command line
#  arguments and displays their sum on the screen    
#  if run with no arguments, it informs user
#  with usage message
#
######################################################

printusageinfo(){
    echo "Usage: $0 number-list"
    exit 1
}
function is_integer() {
    printf "%d" $1 > /dev/null 2>&1
    return $?
}

if [ $# = 0 ]
then
    echo "Usage: $0 number-list"
    exit 1
fi

sum=0 #Running sum initialized to zero
count=0 #To count number of arguments

while [ $# != 0 ]
do
if is_integer $1; then
     # "$1 is an integer"
    sum=`expr $sum + $1`
    count=`expr $count + 1`
    shift # Shift the counted number out
else
        echo "$1 is not an integer"
    printusageinfo   
fi

done

#displaying final sum

echo "The sum of given $count numbers is $sum."
exit 0