Unit4 - Subjective Questions

CSC104 • Practice Questions with Detailed Answers

1

Explain the concept of multi-function scripting in Bash. How does breaking a script into functions improve maintainability?

2

Write a snippet of code to create an interactive menu in Bash using a case statement. Explain how to colorize the output text to make it user-friendly.

3

Distinguish between Pipes (|) and Redirection (>, >>, <) in Bash scripting with examples.

4

Describe two methods to achieve remote script execution over SSH. How can you run a local script on a remote server without copying the file first?

5

What is jq? Explain how it is used to parse JSON data in Bash scripts with an example of extracting a specific value.

6

Explain the significance of Cloudflare API integration in automation. Which command-line tool is primarily used for this, and what HTTP headers are typically required?

7

Design the logic for an Access Log Summarizer script. Which tools would you use to count the top 5 IP addresses hitting a web server?

8

How can SSMTP be used to send automated email alerts from a Bash script? Describe the basic configuration required in /etc/ssmtp/ssmtp.conf.

9

Write a Bash one-liner or short script logic to create a secure Password Generator. Explain the source of randomness used.

10

Outline the steps required to script an Automated WordPress setup on a LAMP stack. What are the four main components involved?

11

In multi-function scripting, what is the difference between local and global variables? Why is using local recommended inside functions?

12

When parsing API responses with jq, how would you extract specific values from a JSON array? Assume the input is [{"id":1}, {"id":2}].

13

Explain the role of Standard Error (stderr) redirection. How do you redirect both output and errors to the same file?

14

In the context of Cloudflare API integration, what is the difference between updating a DNS record via POST vs PUT (or PATCH)?

15

Derive a command using awk and grep for an Access Log Summarizer that specifically counts the number of "404 Not Found" errors in a log file.

16

Discuss the security implications of storing passwords in scripts for Automated WordPress setup or SSMTP. How can this be mitigated?

17

Explain how the select loop differs from the while loop when creating an interactive menu in Bash.

18

When using Remote script execution, how do you handle variables? Specifically, explain the difference between $VAR and $VAR when executing a command over SSH.

19

In a Password Generator script, why is string manipulation (like fold or tr) necessary after reading from /dev/urandom?

20

Describe the specific database automation commands required during an Automated WordPress setup. How do you ensure the WordPress script can access the database?