0% found this document useful (0 votes)
4 views2 pages

Usp Module 3

This document explains the use of 'read' and 'readonly' commands in shell scripting for user input and variable protection. It provides examples of how to take user input and how to declare a variable as read-only, preventing its modification. Additionally, it mentions that shell scripts can accept command line arguments, which are assigned to positional parameters for non-interactive execution.

Uploaded by

1dt25cs427
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Usp Module 3

This document explains the use of 'read' and 'readonly' commands in shell scripting for user input and variable protection. It provides examples of how to take user input and how to declare a variable as read-only, preventing its modification. Additionally, it mentions that shell scripts can accept command line arguments, which are assigned to positional parameters for non-interactive execution.

Uploaded by

1dt25cs427
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MODULE-3

read & readonly commands:


The read statement is the shell's internal tool for taking input from the user, i.e. making script
interactive.
Example:
#!/bin/sh #Sample Shell Script - [Link]
echo "Enter Your First Name:"
read fname
echo "Enter Your Last Name:"
read lname
echo "Your First Name is: $fname"
echo " Your Last Name is: $lname"
read only statement:
Shell provides a way to mark variables as read-only by using the read-only command. After a
variable is marked read-only, its value cannot be changed.
For example, the following script generates an error while trying to change the value of NAME –
#!/bin/sh
NAME="Ramu"
readonly NAME
NAME="Bantu”

Command Line Arguments:


✓ Shell script also accept arguments from the command line. They can, therefore, run non-
interactively and be used with redirection and pipelines. When arguments are specified with a
shell script, they are assigned to positional parameters.
✓ The shell uses following parameters to handle command line arguments:

You might also like