Question
function of each line of following script :-- 1) The following shell script illustrates the use of the read and echo commands. Enter it using
function of each line of following script :--
1) The following shell script illustrates the use of the read and echo commands. Enter it using vi the file should be named mycat. Set the appropriate permissions and test it. Using man pages, Google, your textbook, and class handouts comment each line of the script provided below to explain how the script functions.
! /bin/sh -f
read s
while [ -n "$s" ]
do
echo $s
read s
done
2) The following shell script is used to demonstrate how a script can be written that is able to interact with a user. Enter it using vi the file should be named mydialog. Set the appropriate permissions and test it. Using man pages, Google, your textbook, and class handouts comment each line of the script provided below to explain how the script functions.
#! /bin/sh
echo -n "Enter you name (first last): "
read first last
echo "Data read:" $first $last
cat << ENDDATA
Hi, $first ${last}.
Mr. $last, bye-bye!
ENDDATA
3) The following script can be used to create users. Using man pages, Google, your textbook, and class handouts comment each line of the script provided below to explain how the script functions. There is no need to run this script.
#! /bin/sh -fx
read username
while [ -n "$username" ]
do
name=`echo $username | awk '{print $1}'`
useradd -m -g users -d /home/users/$name -s /bin/bash $name
passwd $name
read username
done
4) The following script can be used to delete users. Set the appropriate permissions and test it. Using man pages, Google, your textbook, and in class handouts comment
each line of the script provided below to explain how the script functions. There is no need to run this script.
#!/bin/bash
read username
while [ -n "$username" ]
do
name=`echo $username | awk '{print $1}'`
userdel -r $name
read username
done
5) This shell script demonstrates the use of the shift instruction. Enter it using vi the file should be named myargs. Set the appropriate permissions and test it. . Using man pages, Google, your textbook, and class handouts comment each line of the script provided below to explain how the script functions.
! /bin/sh -x
echo $#: $@
set abc def ghi
while [ $# -gt 0 ]
do
echo $#: $@
shift
done
6) The following shell script is used to demonstrate how a script can be written that uses procedures called by a driver section of the script. Enter it using vi the file should be named myproc. Set the appropriate permissions and test it. Using man pages, Google, your textbook, and class handouts comment each line of the script provided below to explain how the script functions.
main()
{
proc1()
{
echo ... In proc
return 0
}
echo Calling proc
proc1
echo Back to caller
return 0
}
main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started