JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD MCA 2022 LINUX PROGRAMMING Previous Question Paper (March/April - 2022 - R17)
Answer any five questions. All questions carry equal marks.
Main
Write a shell script to find the factorial of a given number.
Answer
To calculate the factorial of a number in a shell script, you can use a loop structure to multiply the sequence of integers from 1 to the input number.
#!/bin/bash
echo "Enter a number:"
read num
fact=1
if [ $num -lt 0 ]; then
echo "Factorial does not exist for negative numbers."
else
for (( i=1; i<=num; i++ ))
do
fact=$((fact * i))
done
echo "Factorial of $num is $fact"
fiExplain about shell meta characters and shell variables.
Answer
Shell Meta Characters are special characters that have a specific meaning to the shell, rather than being treated as literal text. They are used for pattern matching, redirection, and command control. Examples include:
- *: Matches any string of characters.
- ?: Matches any single character.
- > and <: Used for input/output redirection.
- |: Pipes the output of one command to the input of another.
- ;: Separates multiple commands on a single line.
Shell Variables are used to store data within the shell environment. They are typically defined using the syntax VARIABLE_NAME=value. Variables can be local, existing only within the current shell, or environment variables, which are exported to child processes using the export command. To access the value stored in a variable, the $ prefix is used (e.g., echo $HOME). Variables are essential for script configuration, path management, and storing temporary results during execution.
Explain about the control structures used in shell programming.
Answer
Sign in to view the complete answer paper.
Write a shell program to concatenate two files.
Answer
Sign in to view the complete answer paper.
Write a Perl program to sort the list of element in an array.
Answer
Sign in to view the complete answer paper.
Explain about the Unix file structure.
Answer
Sign in to view the complete answer paper.
Explain the following system calls with complete syntax and examples: chmod, chown, link, symlink, getcwd.
Answer
Sign in to view the complete answer paper.
Explain about the reliable and unreliable signals.
Answer
Sign in to view the complete answer paper.
Explain about the kernel support for process.
Answer
Sign in to view the complete answer paper.
Explain about the wait and waitpid system call.
Answer
Sign in to view the complete answer paper.
Explain about the process control.
Answer
Sign in to view the complete answer paper.
What are pipes? Explain their limitations. Explain how pipes are created and used in IPC with an examples.
Answer
Sign in to view the complete answer paper.
Explain about the Unix kernel support for messages.
Answer
Sign in to view the complete answer paper.
Write client server program using TCP.
Answer
Sign in to view the complete answer paper.
Explain about the Unix API for shared memory.
Answer
Sign in to view the complete answer paper.