Search This Blog

Saturday, September 30, 2023

Shell script 3

Question2:
Write a script whether the file is readable or not, if it is readable print the file content on the terminal after 5 sec

Answer:

Path="/home/kalam/filename.sh"

echo "User provide path is : $Path"

sleep 5

if [ -e $Path ]

then

        echo "file is present in the $Path"

        if [ -r $Path ]

        then

                echo "the file $Path is readable"

                info=$(cat $Path)

                echo $info

        else

                echo "file is not in readable format"

        fi

else

        echo "File is absent in the given path: $Path"

        echo "Please correct the path and rerun the script"

        echo "thank you for using this script"

fi


Output:

User provide path is : /home/kalam/filename.sh

file is present in the /home/kalam/filename.sh

the file /home/kalam/filename.sh is readable

echo "Please Provide the user name and state name" read name state_name echo "User provided name is :$name and His state name is : $state_name " if [ "$state_name" = "andra" ]; then echo "$name speaks Telugu" else echo "$name does not speak Telugu" fi


Note: 
-r flag is used check for readable the file or not if yes condition will execute

Shell script 2

 Shell scripting 2

Question:

Read the user inputs and check for that whether it is available or not ,If it is available print the user inputs are available else print not available , also your output should print after 10 Sec

Answer:

Path="/home/kalam/filename.sh"

echo "User provide path is : $Path"

sleep 10

if [ -e $Path ]

then

        echo "file is present in the $Path"

else

        echo "File is absent in the given path: $Path"

        echo "Please correct the path and rerun the script"

        echo "thank you for using this script"

fi

Output:

User provide path is : /home/kalam/filename.sh

file is present in the /home/kalam/filename.sh

Note:

-e is the flag which is used to check for the existence of the file or directory

Shell script 1

If condition

Example:

echo "Please provide the user name and state name"

read name state_name

echo "User provided name is :$name and His state name is : $state_name "

if [ "$state_name" =  "Andra" ]; then

        echo "$name speaks Telugu"

else

        echo "$name does not speak Telugu"

fi


Output:

Please Provide the user name and state name

Balakrishna andra

User provided name is :Balakrishna and His state name is : andra

Balakrishna speaks Telugu

Shell scripting

Read the user inputs and execute the script

Example1: 

echo  -n  "Please type your required info"

read info

echo "You're required information is: $info"

Example2:

read -p "Please type your required info" info

echo  "You're required information is: $info""


Example and Example2 both gives the same but, in the example1 there is no read -p

Example2 : read -p --> it will ask a query and assigned to var

Wednesday, September 13, 2023

Lists in TCL scripting

 LISTS keywords and It's Usage 

lindex

lindex is a keyword and it will print the index value of the list.
Example:
   set  NameList  "Naresh Prashanth Sanjeev Manoj  Rajendhar"
   puts [lindex $NameList 0] ; #it will print the 0th index of NameList i,e Naresh
   puts [lindex $NameList 1] 
   puts [lindex $NameList 2] 
         
Explanation:

List index will start from "0" 
Naresh    -----> index 0
Prashanth  ---> index 1
Sanjeev     ---> index 2
Manoj      ----> index 3
Rajendhar ---> index 4

*****************************************************************************

llength

llength is a keyword -it will give you the size of the list.

Example:           
  set  NameList  "Naresh Prashanth  Sanjeev Manoj Rajendhar"
  puts [lindex   $NameList 0] 
  puts [llength  $NameList ] ; #it will print 5 because 5 Names are there in the NameList  

****************************************************************************

lsort

lsort is a keyword -it will sort the list means ascending/Descending order of the List      

Example1:
 set  NumList  "0  9 8 1 3 4"
 puts [lsort $NumList  -ascending ] ; # it will print from small to big
 puts [lsort $NumList  -descending ] ; # it will print from big to small 

 Explanation 1:
 In this example I am taking numerical values     
 Ascending values --> small to big like 0 1 3 4 8 9
 Descending values --> big to small like 9 8 4 3 1 0

Example2:         
 set flist  "Banana Anar Avagado Watermelon Grapes Mango "
 puts [lsort $flist] ; # it will print in alphabetical order

*************************************************************************

lsearch

lsearch is a keyword to search for the element if it is matches it will return 0 otherwise it will return -1 

Example:
    set str "Nag Raju Chandu Mahi"
    lsearch $str Nag

************************************************************************


TCL Basics

 TCL  
Tool Command language

Keywords in TCL

  • puts
  • expr
  • $
  • incr
  • info exists
  • split
  • concat

    LIST keywords

    • lindex
    • llength
    • lsort
    • lreplace
    • linsert
    • lappend
    • lsearch
    • lappend

    Saturday, August 12, 2023

    Basics power anaysis

    Power

    • Dynamic power:
      • Power consumed by the cell when it is active mode.
    • Switching Power:
      • Power dissipated by the charging and discharging of the output load capacitance of a cell is called switching power.
      • Switching power of a cell is a function of output load capacitance and the rate of logic transitions.
    • Internal Power:
      • Power dissipated by charging and discharging of internal capacitance within the boundary of the cell is called Internal power.
    • Short circuit power
      • Power dissipated when a small amount of time both the PMOS and NMOS transistors are turns on.
      • there is short circuit established from VDD to VSS.
    • Leakage power
      • Power dissipated by the cell or circuit when it is in stand by mod or inactive mode.
        

    What is the sanity checks you have done for STA?

     Sanity checks for STA: Linking Checks: We need to check., is there any missing modules or missing pins in a library. this is done by link c...