Perl Script

2004-09-21 Thread Chandrakant Bagade
Hello,
I have made on perl script(attached) which do ldapsearch.
When I run that script through perl command it works,but when I called 
it through some programme to view it in browser it never works.My OS 
Win-2000.Any Thing I am missing as some environmental variable or 
something..

Best Regards,
Chandraknt
#!/usr/local/bin/perl
# # $Header: email_imap_config.pl 30-jul-2003.18:34:00 cpolinsk Exp $
#
# email_imap_config.pl
# # Copyright (c) 2003, Oracle Corporation.  All rights reserved.  #
#NAME
#  email_imap_config.pl - one-line expansion of the name
#
#DESCRIPTION
#  Script reads email config data from oid
#
#NOTES
#  other useful comments, qualifications, etc.
#
#MODIFIED   (MM/DD/YY)
#
use strict;
require emd_common.pl;

my $OSNAME = $^O;

my $Second = ;
my $Minute = ;
my $Hour = ;
my $Day = ;
my $Month = ;
my $Year= ;
my $WeekDay = ;
my $DayOfYear = ;

($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear) = localtime(time);
my $RealMonth = $Month + 1;

if($RealMonth  10)
{
   $RealMonth = 0 . $RealMonth; # add a leading zero to one-digit months
}

if($Day  10)
{
   $Day = 0 . $Day; # add a leading zero to one-digit days
}


if($Second  10)
{
   $Second = 0 . $Second; # add a leading zero to one-digit days
}
if($Minute  10)
{
   $Minute = 0 . $Minute; # add a leading zero to one-digit days
}

if($Hour  10)
{
   $Hour = 0 . $Hour; # add a leading zero to one-digit days
}


my $Fixed_Year = $Year + 1900;

my $FormatedTime = $Fixed_Year-$RealMonth-$Day $Hour:$Minute:$Second;


my $ldap_oh=;

EMAGENT_PERL_DEBUG($ARGV[0] :: $ARGV[0]);


if(  ($OSNAME eq MSWin32) or ($OSNAME eq Windows_NT) )
{
#$ldap_oh = $ARGV[0]\\bin\\ldapsearch;
$ldap_oh = C:\\oracle_as\\bin\\ldapsearch;

}
else
{
#$ldap_oh = $ARGV[0]/bin/ldapsearch;
 $ldap_oh = C:/oracle_as/bin/ldapsearch;
}


### ldap parameters

my $ldap_host=umsvr2-sun.us.oracle.com;
my $ldap_port=3060;
my $ldap_username=cn=orcladmin;
my $ldap_password=welcome1;
my $target_type = oracle_ovf;
my $config_name = orclmailprocloglevel;
my $target =  ;
my $output=;

## Do an ldap search first looking at the target level for the data


EMAGENT_PERL_DEBUG(ldap_oh :: $ldap_oh);

$output = `$ldap_oh -h \$ldap_host\ -p $ldap_port -D \$ldap_username\ -w 
$ldap_password -b 
\cn=ovf,cn=OraVmail,cn=umdev04.us.oracle.com,cn=Computers,cn=OracleContext\ cn=ovf 
orclmailprocloglevel`;
print$output;

EMAGENT_PERL_DEBUG(output :: $output);

## Parse the result string and retrieve just the value
my $ldapValue = getLdapValue($output);
##$ldapValue=NOTIFICATION;


## Return the parsed result
print em_result=$ldapValue|$FormatedTime\n;

###
# getLdapValue
# # Takes an ldap search output string and strips the param name and '='
# from the string to retrieve only the attribute value.
###
sub getLdapValue
{
  my $attr_value = ;
  my $ldap_output = shift(@_);

  EMAGENT_PERL_DEBUG(ldap_output :: $ldap_output);

  my @lines = split(\n, $ldap_output);

  if($#lines  0)
  {
  my $attr_line = @lines[1];
  my @attr = split(=, $attr_line);
  $attr_value = @attr[1];
  }

return $attr_value;
}



RE: Perl Script

2004-09-21 Thread Paul Connolly
Your script is making a call to an external ldapsearch executable.
Therefore any problems you are having are related to your CGI
environment and not related to Net::LDAP ('cause you're not using it!)
which is what this list if for.

Paul.

-Original Message-
From: Chandrakant Bagade [mailto:[EMAIL PROTECTED] 
Sent: 21 September 2004 09:43
To: [EMAIL PROTECTED]
Subject: Perl Script

Hello,

I have made on perl script(attached) which do ldapsearch.
When I run that script through perl command it works,but when I called 
it through some programme to view it in browser it never works.My OS 
Win-2000.Any Thing I am missing as some environmental variable or 
something..

Best Regards,
Chandraknt