31 |
|
|
32 |
my $sth; |
my $sth; |
33 |
|
|
34 |
|
open(WHO,"who am i |") || die "who am i? $!"; |
35 |
|
my $db_user=<WHO>; |
36 |
|
chomp $db_user; |
37 |
|
$db_user=~s/\s.+$//g; # OSF obriši sve iza logina |
38 |
|
$db_user=~s/^[^!]+!//g; # Linux obriši hostname |
39 |
|
close(WHO); |
40 |
|
|
41 |
|
open(HOSTNAME,"hostname |") || die "hostname: $!"; |
42 |
|
my $hostname=<HOSTNAME>; |
43 |
|
chomp $hostname; |
44 |
|
close(HOSTNAME); |
45 |
|
|
46 |
|
$sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr(); |
47 |
|
$sth->execute() || die $sth->errstr(); |
48 |
|
my ($ko_id)=$sth->fetchrow_array; |
49 |
|
die "Ne mogu naći odgovarajuću kontakt osobu u tablici unix2ko!\n\tlogin=$db_user host=$hostname\n" if (!defined($ko_id)); |
50 |
|
|
51 |
|
print "kontakt_osoba_id (koja je pokrenula skriptu): $ko_id\n" if ($debug); |
52 |
|
|
53 |
#$sth = $dbh->prepare("select id from kontakt_osobe where e_mail like '%hana%'") || die $dbh->errstr(); |
#$sth = $dbh->prepare("select id from kontakt_osobe where e_mail like '%hana%'") || die $dbh->errstr(); |
54 |
#$sth->execute() || die $sth->errstr(); |
#$sth->execute() || die $sth->errstr(); |
55 |
#($kontakt_osoba_id) = $sth->fetchrow_array(); |
#($kontakt_osoba_id) = $sth->fetchrow_array(); |
70 |
$sth->execute() || die "$sql ",$sth->errstr(); |
$sth->execute() || die "$sql ",$sth->errstr(); |
71 |
|
|
72 |
#my $out_tex="out.tex"; |
#my $out_tex="out.tex"; |
73 |
my $out_tex="$0-out-$$.tex"; |
my $out_tex="out-$$.tex"; |
74 |
|
|
75 |
open(IN,"obavjest.tex") || die "obavjest.tex: $!"; |
open(IN,"obavjest.tex") || die "obavjest.tex: $!"; |
76 |
open(OUT,"> $out_tex") || die "$out_tex: $!"; |
open(OUT,"> $out_tex") || die "$out_tex: $!"; |
110 |
while (my @arr = $sth->fetchrow_array() ) { |
while (my @arr = $sth->fetchrow_array() ) { |
111 |
print join("|",@arr),"\n"; |
print join("|",@arr),"\n"; |
112 |
|
|
113 |
$dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($arr[0],3,'now'::datetime,5)") if (!$debug); |
if (!$debug) { |
114 |
|
$dbh->do("insert into status (osoba_id,kontakt_osoba_id,datum,status_tip_id) values ($arr[0],$ko_id,'now'::datetime,5)") || die $dbh->errstr(); |
115 |
|
} |
116 |
|
|
117 |
seek(IN,$begin_pos,0); |
seek(IN,$begin_pos,0); |
118 |
while(<IN>) { |
while(<IN>) { |