Description
In this assignment, you need to create some Shell Scripts in the linux environment. Using shell script one can write a series of commands in a plain text file. It is just like a batch file in MS-DOS but is more powerful than the MS-DOS batch file. Shell scripts are useful to automate some periodic maintenance activities, helps in creating new commands also it helps the system administrator to avoid writing the same set of commands again and again. To create a shell script, the basic steps are below-
• Use any editor like vi to write shell script.
• After writing the shell script, set execute permission for your script using chmod command. Example:
$ chmod +x your-script-name
$ chmod 755 your-script-name
• To execute the shell script, following command can be used
$ ./your-script-name
Let’s consider the shell script uinfo.sh
#!/bib/bash
After saving the shell script, use the following command to change it to executable
$ chmod +x uinfo.sh
To execute the shell script, type the following
$ ./uinfo.sh
A sample output of the script is as follows-
Hello seed
Today is
You are working in the directory
/home/seed/CS515
There are many good resources on shell script. Some of them are-
https://www.tutorialspoint.com/unix/shell_scripting.htm www.shellscript.sh
1 Tasks to be carried out
Create and initialize a simple text database. For this purpose, you need to create the following scripts.
• Script2: insertRecord.sh will be used to insert records into the table. You need to provide a valid table name as one of the arguments. You can either insert one record at a time or you can insert multiple records using a single script2 invocation. You can use space as field separator.
• Script3: updateRecord.sh will be used to update any field of the table. Use appropriate arguments for table name, field name, record number in the table and the new value using which the record will be updated.
1
2 General Guidelines
3 Sample session
$ ./createTable.sh CPI.tab RollNo Name CPI
NEW TABLE ’CPI.tab’ WITH FIELDS ‘RollNo’, ‘Name’, ‘CPI’ CREATED
$ ./insertRecord.sh CPI.tab -r “2021CS01” -n “Ravi” -c 7.9
RECORD ADDED TO ’CPI.tab’ table with ’RollNo’ 2021CS01, ’Name’ Ravi and ’CPI’ 7.9
$ ./insertRecord.sh CPI.tab 3
Record 1
ENTER VALUES FOR RollNo: “2021CS02”
ENTER VALUES FOR Name: “Kiran”
ENTER VALUES FOR CPI: 8.0
Record 2
ENTER VALUES FOR RollNo: “2021CS03”
ENTER VALUES FOR Name: “Pranay”
ENTER VALUES FOR CPI: 8.4
Record 3
ENTER VALUES FOR RollNo: “2021CS04”
ENTER VALUES FOR Name: “Ali”
ENTER VALUES FOR CPI: 8.1
3 RECORDS ADDED TO ’CPI.tab’ relation
$ cat CPI.tab
RollNo Name CPI
2021CS01 Ravi 7.9
2021CS02 Kiran 8.0
2021CS03 Pranay 8.4
2021CS04 Ali 8.1
$ ./updateRecord.sh CPI.tab -r “2021CS04” CPI 8.7
RECORD WITH ROLLNO 2021CS04 IS UPDATED in ’CPI.tab’ table
$ cat CPI.tab
RollNo Name CPI
2021CS01 Ravi 7.9
2021CS02 Kiran 8.0
2021CS03 Pranay 8.4
2021CS04 Ali 8.7
4 Submission
Create the three shell script files which are createtTable.sh, insertRecord.sh and updateRecord.sh. A assign8README.txt file can be added for any important points that the evaluator must know. Then make an archive with name “assign8.tgz”. Submit this file using the following submission link only.
https://www.iitp.ac.in/~samrat/CompSysLab2_CS515/submission/
2




Reviews
There are no reviews yet.