--- print/print.pl 2000/04/26 12:21:19 1.2 +++ print/print.pl 2000/06/02 07:07:27 1.5 @@ -31,6 +31,25 @@ my $sth; +open(WHO,"who am i |") || die "who am i? $!"; +my $db_user=; +chomp $db_user; +$db_user=~s/\s.+$//g; # OSF obriši sve iza logina +$db_user=~s/^[^!]+!//g; # Linux obriši hostname +close(WHO); + +open(HOSTNAME,"hostname |") || die "hostname: $!"; +my $hostname=; +chomp $hostname; +close(HOSTNAME); + +$sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr(); +$sth->execute() || die $sth->errstr(); +my ($ko_id)=$sth->fetchrow_array; +die "Ne mogu naći odgovarajuću kontakt osobu u tablici unix2ko!\n\tlogin=$db_user host=$hostname\n" if (!defined($ko_id)); + +print "kontakt_osoba_id (koja je pokrenula skriptu): $ko_id\n" if ($debug); + #$sth = $dbh->prepare("select id from kontakt_osobe where e_mail like '%hana%'") || die $dbh->errstr(); #$sth->execute() || die $sth->errstr(); #($kontakt_osoba_id) = $sth->fetchrow_array(); @@ -44,7 +63,7 @@ if (! defined($print_only_id)) { $sql="select osoba_id,max(status_tip_id) from status where osoba_id > $last_print_id group by osoba_id"; } else { - $sql="select osoba_id,status_tip_id from status where osoba_id=$print_only_id and status_tip_id=3"; + $sql="select osoba_id,status_tip_id from status where osoba_id in ($print_only_id) and status_tip_id=3"; } $sth = $dbh->prepare("$sql") || die "$sql ",$dbh->errstr(); @@ -91,7 +110,9 @@ while (my @arr = $sth->fetchrow_array() ) { print join("|",@arr),"\n"; - $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) { + $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(); + } seek(IN,$begin_pos,0); while() {