/[informatika.old]/print/print.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /print/print.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dpavlin, Wed Apr 26 12:21:19 2000 UTC revision 1.7 by dpavlin, Thu Feb 15 08:35:22 2001 UTC
# Line 31  $dbh->do("set datestyle = 'german'") || Line 31  $dbh->do("set datestyle = 'german'") ||
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    if ($db_user eq "") {
41            open(ID,"id |") || die "id: $!";
42            my $foo=<ID>; chomp $foo;
43            if ($foo=~/uid=\d+\((\w+)\)/) {
44                    $db_user=$1;
45            } else {
46                    die "can't locate who is local user!";
47            }
48    }
49    
50    open(HOSTNAME,"hostname |") || die "hostname: $!";
51    my $hostname=<HOSTNAME>;
52    chomp $hostname;
53    close(HOSTNAME);
54    
55    $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr();
56    $sth->execute() || die $sth->errstr();
57    my ($ko_id)=$sth->fetchrow_array;
58    die "Ne mogu naći odgovarajuću kontakt osobu u tablici unix2ko!\n\tlogin=$db_user host=$hostname\n" if (!defined($ko_id));
59    
60    print "kontakt_osoba_id (koja je pokrenula skriptu): $ko_id\n" if ($debug);
61    
62  #$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();
63  #$sth->execute() || die $sth->errstr();  #$sth->execute() || die $sth->errstr();
64  #($kontakt_osoba_id) = $sth->fetchrow_array();  #($kontakt_osoba_id) = $sth->fetchrow_array();
# Line 44  my $sql; Line 72  my $sql;
72  if (! defined($print_only_id)) {  if (! defined($print_only_id)) {
73          $sql="select osoba_id,max(status_tip_id) from status where osoba_id > $last_print_id group by osoba_id";          $sql="select osoba_id,max(status_tip_id) from status where osoba_id > $last_print_id group by osoba_id";
74  } else {  } else {
75          $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";
76  }  }
77    
78  $sth = $dbh->prepare("$sql") || die "$sql ",$dbh->errstr();  $sth = $dbh->prepare("$sql") || die "$sql ",$dbh->errstr();
79  $sth->execute() || die "$sql ",$sth->errstr();  $sth->execute() || die "$sql ",$sth->errstr();
80    
81  #my $out_tex="out.tex";  #my $out_tex="out.tex";
82  my $out_tex="$0-out-$$.tex";  my $out_tex="out-$$.tex";
83    
84  open(IN,"obavjest.tex") || die "obavjest.tex: $!";  open(IN,"obavjest.tex") || die "obavjest.tex: $!";
85  open(OUT,"> $out_tex") || die "$out_tex: $!";  open(OUT,"> $out_tex") || die "$out_tex: $!";
# Line 91  $sth->execute() || die $sth->errstr(); Line 119  $sth->execute() || die $sth->errstr();
119  while (my @arr = $sth->fetchrow_array() ) {  while (my @arr = $sth->fetchrow_array() ) {
120          print join("|",@arr),"\n";          print join("|",@arr),"\n";
121    
122          $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) {
123                    $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();
124            }
125    
126          seek(IN,$begin_pos,0);          seek(IN,$begin_pos,0);
127          while(<IN>) {          while(<IN>) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26