ftp.nice.ch/pub/next/unix/database/sybperl.1.0.N.b.tar.gz#/sybperl/eg/capture.pl

This is capture.pl in view mode; [Download] [Up]

#! /usr/local/bin/sybperl

#
#	@(#)capture.pl	1.1	6/24/92
#

require "sybperl.pl";
require "sql.pl";

#
# Log us in to Sybase.
#
$d = &dblogin;

&sql($d, "set statistics io on");
&sql($d, "set statistics time on");

#
# Count the number off password tables.
#
@results = &sql($d, '
		select count(*) from sysobjects
		where name = "password" and type = "U"'
	   );

#
# If there is none create it else truncate it.
#
if(@results[0] == 0) {
	&sql($d, '
		create table password(
		    username char(8),
		    uid int,
		    gid int,
		    shell varchar(30),
		    home varchar(30)
		)'
	);
	print "The password table has been created.\n";
} else {
	&sql($d, 'truncate table password');
	print "The password table already exists. Table truncated!\n";
};

#
# Read the password entries and add them to the database.
#
while (($n,$p,$u,$g,$q,$c,$gc,$d,$s)= getpwent) {
	print "Adding $n.\n";
	&sql($d, "
		insert password
		values(\"$n\", $u, $g, \"$s\", \"$d\")
		"
	);
};
endpwent;

#
# Count the number off group tables.
#
@results = &sql($d, '
		select count(*) from sysobjects
		where name = "groups" and type = "U"'
	   );

#
# If there is none create it else truncate it.
#
if(@results[0] == 0) {
	&sql($d, '
		create table groups(
		    groupname char(8),
		    gid int
		)'
	);
	print "The groups table has been created.\n";
} else {
	&sql($d, 'truncate table groups');
	print "The groups table already exists. Table truncated!\n";
};

#
# Read the group entries and add them to the database.
#
while (($gn,$gp,$gg,$gm)= getgrent) {
	print "Adding group $gn.\n";
	&sql($d, "
		insert groups
		values(\"$gn\", $gg)
		"
	);
};
endgrent;

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.