I added the pages that the ques ask to follow the page number.
please answer all the ques.
no ones giving the proper answer
Name • Exercise 1: Please write the example shell script from page 7 and 11 on your computer. Please name your file to "sysinfo_page_8". We will use this in next session. • Exercise 2: Please complete the script in exercise 1 by filling these four functions, system_info(), show_uptimel), drive_space(), home_space(). Please name your file to "sysinfo_page_9". • Exercise 3: write a script to test the existence of "sysinfo_page_9", print the message "You have sysinfo_page_9, you did exercise 2." If yes, print "You do not have sysinfo_page_9, you did not do exercise 2." • Exercise 4: Please write the two example scripts to your server and run it. Page 33 and 36. • Exercise 5: Please write a script that ask user to enter a password, and display it to screen. Use -s option for input the password. • Exercise 6: Please write the two example scripts to your server and run it. Page 44 and 45. • Exercise 7: Write the script to do the following, Ask user to enter an integer, and output whether the given number is even or odd.
7 / 46 61% + Page 7 #!/bin/bash # sysinfo_page - A script to produce an system information HTML file ##### Constants TITLE="System Information for $HOSTNAME" RIGHT_NOW=$(date + "$x $r $2") TIME_STAMP="Updated on SRIGHT_NOW by $USER" ##### Functions system_info() () show_uptime() () drive_space() { } home_space() () ##### Main cat <<- EOF <html> <head> <title>$TITLE</title> </head> <body> <h1>$TITLE</h1> <p>$TIME_STAMP</p> $(system_info) $(show_uptime) $(drive_space) $(home_space) </body> </html> _EOF
11 / 461 61% + 1 Page 11 ##### Main cat <<- _EOF <html> <head> <title>$TITLE</title> </head> #!/bin/bash ##### Constants TITLE="System Information for $HOSTNAME RIGHT_NOW=$(date +"%x%r%Z") TIME_STAMP="Updated on $RIGHT_NOW by $USER" ##### Functions system_info() # Temporary function stub echo "function system_info" 3 show_uptime() 0 # Temporary function stub echo "function show_uptime 1 drive_space() # Temporary function stub echo "function drive_space" } home_space() { # Temporary function stub echo "function home_space" <body> <h1>$TITLE</h1> <p>$TIME_STAMP</p> $(system_info) $(show_uptime) $(drive_space) $(home_space) </body> </html> EOF
33/46 61% + 10 Page 33 read • To get input from the keyboard, you use the read command. The read command takes input from the keyboard and assigns it to a variable. Here is an example: #!/bin/bash echo -n "Enter some text > ". read text echo "You entered: $text" . As you can see, we displayed a prompt on line 3. Note that "-n" given to the echo command causes it to keep the cursor on the same line; i.e., it does not output a linefeed at the end of the prompt.
36 / 46 61% + 10 Page 36 Read #!/bin/bash echo-n "Hurry up and type something! > if read -t 3 response; then echo "Great, you made it in time!" else echo "Sorry, you are too slow!" fi • The -s option causes the user's typing not to be displayed. This is useful when you are asking the user to type in a password or other confidential information.
44 / 461 61% + 10 Page 44 Example #!/bin/bash number=0 echo -n "Enter a number > ". " read number echo "Number is $number" if [ $((number % 2)) -eq 0 ]; then echo "Number is even" else echo "Number is odd" fi
45 / 46 61% + 10 Page 45 Example #!/bin/bash seconds=0 echo -n "Enter number of seconds > " read seconds hours=$((seconds / 3600)) seconds=$((seconds % 3600)) minutes=$((seconds / 60)) seconds=$((seconds % 60)) echo "$hours hour(s) $minutes minute(s) $seconds second(s)"
I added the pages that the ques ask to follow the page number. please answer all the ques. no ones giving the proper ans
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
I added the pages that the ques ask to follow the page number. please answer all the ques. no ones giving the proper ans
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!