Hello, This HW must be done in virtualbox Ubantu taking screen shots of each step progress. Instructions Create a script, called args.sh. As a sanity check, add the line: echo "hello, world", and run...

1 answer below »

Hello,


This HW must be done in virtualbox Ubantu taking screen shots of each step progress.


Instructions



  • Create a script, called args.sh. As a sanity check, add the line: echo "hello, world", and run the script.

  • Print out $0.




    • What does this contain?




  • Print out $1.




    • What happens when you run the script
      with
      arguments?

    • What happens when you run the script
      without
      arguments?




  • Write a script that accepts
    three
    arguments from the user, then prints out the following:




    • The name of the script

    • The value of each argument



Part 2




Instructions



  • Create a new directory, called /usr/scripts, and move into it.

  • Create a script called mkdircd. Add the shebang line #!/bin/bash





    • Note: Remember that the shebang line must be the
      first
      line in the file.




  • Begin writing your script. It should:




    • Create a directory using the first positional parameter

    • Move into that directory

    • Create a file using the second positional parameter

    • Open this file with nano




  • Give your script execution permissions.





    • Hint: chmod




  • Run ./mkdircd ExampleDirectory FirstFile to test.


Part 3




Instructions



  • Create a variable, called PREFIX, and set it equal to the script's first argument.





    • Note: Expect users to pass an argument like 192.168.1—not
      a full IP address.




  • Print the message: Scanning $PREFIX.0/24...

  • Use seq to write a loop that prints every number between 1 and 5.

  • Update your loop to use PREFIX and the number from seq to print out IP addresses. For example, if PREFIX="192.168.1", your loop should print 192.168.1.1; 192.168.1.2; etc.





    • Hint: You can use multiple variables in a string, as in echo "$FIRST_VARIABLE $SECOND_VARIABLE.




  • Inside your loop, create a variable called TARGET. Set it equal to the IP address you created above.





    • Hint: Replace echo with TARGET=.




  • Finally, update your loop to ping the TARGET
    once. Use the -c flag. When it works as expected, update your seq statement to generate numbers up to 255.


Challenges




  • Challenge 3a: Redirect the output of ping to /dev/null. Then:




    • If the ping is successful, print: $TARGET is UP

    • If the ping is
      not
      successful, print: $TARGET is DOWN


    • Hint: You can "chain" operators, like: cat nonexistent_file && echo "File exists!" || echo "File does not exist :("





  • Challenge 3b




    • Redirect the $TARGET is UP message to a file called live_hosts. Be sure to
      append
      to the file with >> instead of using > (why?).

    • Redirect the $TARGET is DOWN message to a file called down_hosts.

    • Print the contents of each file after the loop completes.


Answered Same DayAug 05, 2021

Answer To: Hello, This HW must be done in virtualbox Ubantu taking screen shots of each step progress....

Sonu answered on Aug 06 2021
157 Votes
Virtual Box/1..JPG
Virtual Box/10..png
Virtual Box/11..png
Virtual Box/12..png
Virtual Box/14.jp
g
Virtual Box/15.png
Virtual Box/18.jpg
Virtual Box/2..JPG
Virtual Box/3..JPG
Virtual Box/4.png
Virtual Box/5..png
Virtual Box/6..png
Virtual Box/7..png
Virtual Box/9..png
Virtual...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here