Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with UNIX on bash shell. Create a sqlite3 database (called mypasswd) and create a table (passwd) to load the passwd information from /etc/passwd file

Help with UNIX on bash shell.

Create a sqlite3 database (called mypasswd) and create a table (passwd) to load the passwd information from /etc/passwd file as shown below.

{cleacslinux1:~/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

Then this part

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.

For the first record: root:x:0:0:root:/root:/bin/bash

apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin

Then this part

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 cs3376" 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 cs3376", 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_2

Step: 3

blur-text-image_3

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions