Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN UNIX: PLEASE DO AND PROVIDE SCREENSHOTS OF THE PROGRAMS RUNNING, ill give you a good rating. thanks Design and implement C/C++ program (a3part1.c [or

IN UNIX: PLEASE DO AND PROVIDE SCREENSHOTS OF THE PROGRAMS RUNNING, ill give you a good rating. thanks

Design and implement C/C++ program (a3part1.c [or a3part1.cpp]) to do the following tasks and make a Makefile to compile the program, and to run the program to show each task done.

The following commands (cat /etc/passwd and cat/etc/passwd | wc) show the part of the passwd file and the number of the line of the file: 58.

{cslinux1:~} cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync

{cslinux1:~} cat /etc/passwd | wc 58 135 3266

Your program is to do the following tasks. ............................. Task #1. ............................. Create a sqlite3 database (called mypasswd) and create a table (passwd) to load the passwd information from /etc/passwd file as shown below.

[You should keep the session log of this task as shown below as an example (to copy and paste) in this document below, to show your activity done.]

{cslinux1:~/sqlite/passwd} sqlite3 mypasswd SQLite version 3.14.1 2016-08-11 18:53:32 Enter ".help" for usage hints. sqlite> create table pwtable (user, pass, uid, gid, gecos, home, shell); sqlite> .separator : sqlite> .import /etc/passwd pwtable sqlite> select * from pwtable where user='root'; root:x:0:0:root:/root:/bin/bash sqlite> select * from pwtable; root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin sqlite> .exit

.................................. Task #2 ................................... Your C program (a3p1task2.c) connect to the database and get all the entries in the pwtable (from Task#1) and output each record in a file ("a3p1task2.txt"). Each record should be formatted as shown below.

Record 1 user: root uid: 0 gid: 0 gecos: root home: /root shell: /bin/bash

Record 2

For the first record: root:x:0:0:root:/root:/bin/bash apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin ............................................ Task #3 ............................................. Your program does an update to the sqlite3 database to do an update to a record where uid=48 for the gecos (comment) field to be updated as "My Apache Server for cs3377" as shown below. update pwtable set gecos="My Apache Server for cs3377" where uid="48";

Your program does (interacting with sqlite3 database): (1) get the record (of uid=48) and print the record with the headings shown in Task#2, (2) update the record (of uid=48) so that the gecos will be "My Apache Server for cs3377", then (3) get the updated record using select, and (4) print the record to the console with a heading (as shown in Task #2).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

Students also viewed these Databases questions

Question

Distinguish between filtering and interpreting. (Objective 2)

Answered: 1 week ago