/[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.4 by dpavlin, Wed May 31 14:32:39 2000 UTC revision 1.5 by dpavlin, Fri Jun 2 07:07:27 2000 UTC
# Line 34  my $sth; Line 34  my $sth;
34  open(WHO,"who am i |") || die "who am i? $!";  open(WHO,"who am i |") || die "who am i? $!";
35  my $db_user=<WHO>;  my $db_user=<WHO>;
36  chomp $db_user;  chomp $db_user;
37  $db_user=~s/\s.+$//g;  $db_user=~s/\s.+$//g;   # OSF obriši sve iza logina
38    $db_user=~s/^[^!]+!//g; # Linux obriši hostname
39  close(WHO);  close(WHO);
40    
41  open(HOSTNAME,"hostname |") || die "hostname: $!";  open(HOSTNAME,"hostname |") || die "hostname: $!";
# Line 42  my $hostname=<HOSTNAME>; Line 43  my $hostname=<HOSTNAME>;
43  chomp $hostname;  chomp $hostname;
44  close(HOSTNAME);  close(HOSTNAME);
45    
46  my $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr();  $sth = $dbh->prepare("select ko_id from unix2ko where login='$db_user' and host='$hostname'") || die $dbh->errstr();
47  $sth->execute() || die $sth->errstr();  $sth->execute() || die $sth->errstr();
48  my ($ko_id)=$sth->fetchrow_array;  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();
# Line 106  $sth->execute() || die $sth->errstr(); Line 110  $sth->execute() || die $sth->errstr();
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],$ko_id,'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>) {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.26