#!/usr/bin/perl4.036

# Filename:  	import_taglines
# Purpose:	import the taglines file into the messages tagline database.
# Author:	Greg Shaw
# Created:	6/19/96

# check for BBSDIR
if (!$ENV{"BBSDIR"})
{
	die "Please run this script as user bbs."
}

# tagfile
$tag = join('',"<",$ENV{"BBSDIR"},"/text/tagfile");

# open files
open(TAGFILE, $tag) || die "Can't open $tagfile.";
open(OUTFILE, '>/tmp/importtags') || die "Can't open /tmp/importtags file.";

# head file
print OUTFILE $ENV{"BBSDIR"},"/msql/bin/msql rocat << EOF\n";

# now start import
while (<TAGFILE>) {
	chop;
	next if (/^#/);  # skip comments
	($tagid,$line) = split("\t",$_,2);
	$line =~ s/\'/\\\'/g;	# turn backtics into quoted backtics
	printf(OUTFILE "insert into tagline values (%d,'%s')\\g\n",$tagid,$line);
}

close OUTFILE;

# now send into msql

system join('',"/bin/sh","</tmp/importtags");
unlink "/tmp/importtags";
