Professional Documents
Culture Documents
PART-I: MCS-041
Question 1:
Write the UNIX commands for the following:
(a) To wait for a specified number of seconds before exit.
Ans.
root@devx:/ # date; sleep 5; date
root@devx:/ #
[1] 745564
root@devx:/ #
(b) To arrange to print a file on the line printer without making you wait for the command to
finish.
Ans.
(c) What are the differences among the following three commands?
i. cat file | pr
ii. pr < file
iii. pr file
Ans
Ans
Are you sick of seeing the same old prompt whenever you go to the "DOS/Command Prompt" --
"C:\>" for example?
PROMPT
followed by the format characters for your new prompt (only a few format characters are
listed below to keep the compatibility. to find out all the codes available to you in your
operating system, type "PROMPT/?" without the quotes and press ENTER):
$d -- current date
$t -- current time
$g -- ">" character
$p -- current path/directory
for example:
PROMPT $t $p $g
• Press ENTER
E ) To grant the permissions of read, write and execute to the user and read only to the group and
others for any file using chmod.
Ans.
Ans.
$ fortune | tee >(?stdout?) | pbcopy
"...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
the Ugly)."
(g) To print all the filenames in the current directory that doesn’t contain the temp.
Ans .
(h) To list all the filenames that others can read and write.
Ans.
(i) To split a file test, which is containing 100 lines into 25 lines each.
Ans.
(head -100 > f1.txt; cat > f2.txt) < input.txt >
(j) To display those lines that are common to file1 and file2.
Ans.
Question 2:
(a) Write a shell program to translate all the lower case letters in any text file to the upper case
letters.
Ans.
1 #!/bin/bash
2 # get filename
3 echo -n "Enter File Name : "
4 read fileName
5 # make sure file exits for reading
6 if [ ! -f $fileName ]; then
7 echo "Filename $fileName does not
8 exists"
9 exit 1
10 fi
11 # display last five lines of the file using
12 tail command
13 tail -5 $fileName
(c) Write a shell script to display the list of the files whose filename consists of 4 characters (with
any file extension) and filename starts with the alphabet f.
Ans.
PART-II: MCS-043
Question 1:
Design a database for maintaining inventory of a retail shop. You are required to perform the
following activities for the maintenance of the above:
(a) Create the database.
Ans.
categoryname varchar(255),
description varchar(255),
daterecorded date
);
(ii) Find the details of the six items in terms of numbers/quantity in alphabetical order that
have got the maximum sale.
Ans.
Select Max(tblsales.total) from tblsales, tbladjustitemqty
Where tbladjustmentempty.id = tblsales.id order by desc
(iii) Find the names of those items that have an overall sale of 40% of what have been procured.
Ans.
(iv) Create a view of the items for the manager showing overall performance of the week for
each item.
Ans.
(c) Create the procedures for the queries (i) to (iii) above.
Ans.
Ans.
mysql> CREATE TABLE account (acct_num INT, amount DECIMAL(10,2));
Query OK, 0 rows affected (0.03 sec)
mysql> CREATE TRIGGER ins_sum BEFORE INSERT ON account
(ii) Create a trigger that increases the price of a specific item by a certain percentage on a
specific weekend.
Ans.
(e) reate a transaction that finds the total items sold per week and prints the overall
revenue generated.
Ans.
SELECT
[Order Details].OrderID, [Order Details].ProductID, Products.ProductName, [Order
Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount, CCur([Order
Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice
FROM Products
ON Products.ProductID=[Order Details].ProductID
(f) Create two different types of users: the first user – a manager who can see reports and change
the items and its price value and second user who sells these items.
Ans.
The ORDER BY clause of the SELECT query lets you specify the sequence of rows in the final result
set. As you'll learn in later chapters, you can actually embed a SELECT statement within another
SELECT statement or SELECT expression to answer very complex questions. However, the SELECT
query cannot be embedded at any level.