Connect to MSSQL through PERL on FreeBSD* - sql-server

I am tryin to connect to mssql through perl on freebsd.
On Linux it was easy:
apt-get install libdbi-perl freetds-bin libdbd-sybase-perl
After that i create freetds.conf file with settings. Example:
[MSSQL]
host = %my server%
port = 1433
tds version = 7.0
And its work. For the same logic i tryed:
cd /usr/ports/databases/p5-DBI/ && make install clean
cd /usr/ports/databases/freetds/ && make install clean
cd /usr/ports/databases/p5-DBD-Sybase/ && make install clean
Then i run same code from Linux:
use DBI;
my $hostname = 'MSSQL';
my $database = %my database%;
my $user = %my user%;
my $pass = %my password%;
my $dbh = DBI->connect("DBI:Sybase:server=$hostname;database=$database", $user, $pass);
And i get:
DBI connect('server=MSSQL;database=%my database%, %user%, %password%) failed: (no error string)
I will appreciate for any help.

You also can install packages on your freebsd box using pkg tool.
So, something like this:
pkg install p5-DBI p5-DBD-Sybase freetds
About your perl check-up script, I guess that you need to also include:
use DBD:Sybase;
And I will give a try to change DBI:Sybase:server=... to dbi:Sybase:server=...
But if you need make sure, check this url: http://search.cpan.org/~mewp/DBD-Sybase-1.15/Sybase.pm
Hope that my 0.002 helps! ;-)

It seems different versions of Sybase.pm have different DBI->connect arguments parsing logic.
I've just found that Sybase.pm $Id 1.115$ doesn't work with calls of form
DBI->connect('DBI:Sybase:server=mydbhost:database=dbname','username','password')
(note the colon between 'mydbhost' and 'database') while Sybase.pm $Id 1.44$ perfectly does.
Or is it a difference in DBI?
Posting it here for googlers.

Related

Unable to allocate new TLS context

I have postfix 3.3.0 and Active Directory on Server 2019. I want the connection to be secure and to validate the server certificate.
When trying to send an email, I am unable to and see this in syslog.
postfix/submission/smtpd[7432]: warning: dict_ldap_set_tls_options: Unable to allocate new TLS context -1: Can't contact LDAP server
Here's the contents of /etc/postfix/ldap-users.cf
bind = yes
bind_dn = {valid bind account}
bind_pw = {valid bind password}
version = 3
timeout = 20
size_limit = 1
expansion_limit = 0
start_tls = yes
tls_require_cert = yes
tls_ca_cert_file = /var/spool/postfix/mydomain.tld.crt
server_host = ldap://dc.mydomain.tld/
search_base = dc=mydomain,dc=tld
scope = sub
query_filter = (&(objectClass=person)(mail=%s))
result_attribute = mail
result_format = %s
With this configuration, postmap -q test#mydomain.tld ldap:/etc/postfix/ldap-users.cf works. openssl s_client -starttls ldap -connect dc.mydomain.tld:389 also works (no validation errors). Even with tls_require_cert = no, it still fails. When start_tls = no, everything works fine.
Before I specified tls_ca_cert_file, I imported my .crt into ca-certificates. The error I received was postfix/postmap[4994]: error: dict_ldap_connect: Unable to set STARTTLS: -11: Connect error. It seems Postfix doesn't read from the computer cert store. After testing with tls_ca_cert_file from my home, it changed to the error I'm getting now, -1. I first tried from /etc/postfix, then now chroot home (based on an Internet suggestion Postfix couldn't access it).
I realized I made the classic mistake of installing from the stock repositories, and ended up with an old version. I ended up compiling Postfix from source.
sudo groupadd postfix
sudo groupadd postdrop
sudo useradd -c "Postfix Daemon User" -d /var/spool/postfix -g postfix -s /bin/false -u 32 postfix
wget http://cdn.postfix.johnriley.me/mirrors/postfix-release/official/postfix-3.6.2.tar.gz
tar xzf postfix-3.6.2.tar.gz
sudo apt-get install libdb-dev gcc m4 make libsasl2-dev openssl libssl-dev libldb-dev libldap2-dev
cd postfix-3.6.2/
make makefiles CCARGS="-I/usr/include/openssl -I/usr/include/sasl/ -DUSE_TLS -DHAS_LDAP -DUSE_SASL_AUTH -DUSE_CYRUS_SASL" AUXLIBS="-lssl -lcrypto -lldap -llber -lsasl2"
make
sudo make install

Problems with mod_auth_token installation

TOOLS
apache2 -v : Server version: Apache/2.4.7 (Ubuntu)
ubuntu 14.04 LTS
I'd like to install mod_auth_token to secure some of my files but I'm having problems with the first command I need to run:
Command
./configure
Error message
configure: error: APXS not found in $PATH, please use with-apxs to specify the location of the apxs binary
Except that locate apxs returns none so I guess it's nowhere and
echo $PATH -> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Any ideas ?
UPDATE1
Found it, apxs2 was missing, to add it apt-get install apache2-dev
But now when I run make or make check or make install I get a warning and the installation stops:
mod_auth_token.c:65:3: warning: missing sentinel in funcgtion call [ -Wformat=]
ap_set_string_slot(cmd, config, apr_pstrcat(cmd->pool, arg, '/'));
^
Code
if (arg[len -1] != '/') {
/*here*/ ap_set_string_slot(cmd, config, apr_pstrcat(cmd->pool, arg, '/'));
conf->prefix_len = len + 1;
....
I was having this issue and developer here figured this for me (thanks Bill!).
According to Apache Docs https://apr.apache.org/docs/apr/1.6/group__apr__strings.html#ga7bd80c95ffb7b3f96bc78e7b5b5b0045 "The final string must be NULL"
He changed that line to:
ap_set_string_slot(cmd, config, apr_pstrcat(cmd->pool, arg, '/', NULL));
and it compiled.

How to list packages and dependencies that will be installed in Macports?

Is there a way to just list all new packages and their dependencies that port will install for a given command?
For instance, consider installing the SciPy stack with the suggested:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
That installs a ton of packages and dependencies not listed in the above command.
Also, some of them I already have.
I'm already aware of the -y switch but that gives a verbose output of everything, including packages I had already installed.
I'm interested to have port tell me which new packages (be it dependencies or not) will be installed.
Is there a known way or do people just parse the -y output of the command, comparing each reported package against the existing installed packages?
Cheers
p.s. I'm fairly new to Macports and MacOSX (in Linux, apt-get always tells you which new packages will be installed)
You can use a port expression to print what will be installed:
port echo rdepof:$yourport and not installed
or for multiple ports
port echo \( rdepof:$yourport rdepof:$yourport2 ... \) and not installed
Due to the number of Portfiles involved in this and how the set operations are implemented, this will be rather slow. That being said, we're also working on improving this and providing feedback prior to installation like apt-get in a future MacPorts version.
neverpanic already gave a answer, but it seems unable to handle variants (like +notebook) and command-line options (like configure.compiler=macports-clang-3.7). I had a separate solution. The following Python script can display the new dependencies recursively:
#!/usr/bin/env python
#coding: utf-8
import re
import sys
import subprocess
# Gets command output as a list of lines
def popen_readlines(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait()
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, cmd)
else:
return map(lambda line: line.rstrip('\n'), p.stdout.readlines())
# Gets the port name from a line like " gcc6 #6.1.0_0 (active)"
def get_port_name(port_line):
return re.sub(r'^ (\S+).*', r'\1', port_line)
# Gets installed ports as a set
def get_installed():
installed_ports_lines = popen_readlines(['port', 'installed'])[1:]
installed_ports = set(map(get_port_name, installed_ports_lines))
return installed_ports
# Gets port names from items that may contain version specifications,
# variants, or options
def get_ports(ports_and_specs):
requested_ports = set()
for item in ports_and_specs:
if not (re.search(r'^[-+#]', item) or re.search(r'=', item)):
requested_ports.add(item)
return requested_ports
# Gets dependencies for the given port list (which may contain options
# etc.), as a list of tuples (combining with level), excluding items in
# ignored_ports
def get_deps(ports, ignored_ports, level):
if ports == []:
return []
deps_raw = popen_readlines(['port', 'deps'] + ports)
uninstalled_ports = []
for line in deps_raw:
if re.search(r'Dependencies:', line):
deps = re.sub(r'.*Dependencies:\s*', '', line).split(', ')
uninstalled_ports += [x for x in deps if x not in ignored_ports]
ignored_ports |= set(deps)
port_level_pairs = []
for port in uninstalled_ports:
port_level_pairs += [(port, level)]
port_level_pairs += get_deps([port], ignored_ports, level + 1)
return port_level_pairs
def main():
if sys.argv[1:]:
ports_and_specs = sys.argv[1:]
ignored_ports = get_installed() | get_ports(ports_and_specs)
uninstalled_ports = get_deps(ports_and_specs, ignored_ports, 0)
for (port, level) in uninstalled_ports:
print ' ' * (level * 2) + port
if __name__ == '__main__':
main()
It can be invoked like port_rdeps.py libomp configure.compiler=macports-clang-3.7. As a bonus, it can show the uninstalled dependencies as a tree.

How to use Axis2c to generate C files from WSDL file

I want to use a webservice in C code. I am trying to make a client. I need something to do what Axis2java does and generates the classes from a wsdl files.
I found that Axis2c makes (.c) files generated from wsdl file.
I downloaded it from here . unzipped it. I created the environment variable for AXIS2C_HOME and I created AXIS2C_CLASSPATH.
but I can't make it work.
when I type this command :
WSDL2C -uri -ss -sd -d none -u -f -o
I get this error :
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
how can I solve this problem. and please tell me how to use this Axis2c tool properly.
Thank you in advance.
#loentar : I installed Axis2/Java and I set the environment variable for it. now I run the wsdl2c.bat I get this :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
after that I run this command :
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat -uri hello.wsdl
-u -uw
E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Unrecognized option: -uri
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
what can I do ?
I'm using windows 8 by the way.
In addition to Axis2/C you must have Axis2/Java installed.
AXIS2_HOME must point to Axis2/Java installation.
For details please see README of codegen.
The complete list of commands to create and compile client is:
# create stubs
sh $AXIS2C_HOME/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -uw
# implement main() in src/your_client.c
# see samples/codegen/client/calculator for example
# compile and link client
gcc -o calculator_client src/*.c -I$AXIS2C_HOME/include/axis2-1.6.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib
I set the envinroment variable for JAVA_HOME, AXIS2_HOME, AXIS2C_HOME, and added their lib folder to CLASSPATH. after running this command:
WSDL2C.bat -uri hello.wsdl -u -uw
I got this message:
echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
I found the solution myself. :)
I double checked if I had created the environment variable for AXIS2_HOME and I saw that it is there, correctly.
in spite of it's existence I tried to set it again in command prompt. so I typed:
SET AXIS2_HOME=E:\dev\Tools\axis2-1.6.2
then I typed the command for WSDL2C code generator:
WSDL2C.bat -uri hello.wsdl -u -uw
And BAM ! it worked properly.
Now I can generate C files from WSDL file.

how to run local blast program in apche2 server

I am running a local blast program in apche2 server...but it showing me error that.
--------------------- WARNING ---------------------
MSG: cannot find path to blastall
My code is..
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use Bio::Perl;
use Bio::Tools::Run::StandAloneBlast;
#params = ('database' => 'btaudb','outfile' => 'bla.out',
'_READMETHOD' => 'Blast', 'prog'=> 'blastn');
$factory = Bio::Tools::Run::StandAloneBlast->new(#params);
$str = Bio::SeqIO->new(-file=>'test_query.fa' , '-format' => 'Fasta' );
$input = $str->next_seq();
$factory->blastall($input);
when i am running the same code in terminal its working fine...and showing mw correct result....pl help me..how to run local balst program in apche2 server.....
In my experience, that message means that you do not have the "blastall" tool available in your path. That is, if you typed "blastall -p blastn -d dbname -i input -o output" at your commandline, as was normal usage, your shell would complain about not being able to find blastall.
The Blastall interface appears to be on its way out, as noted here: http://www.ncbi.nlm.nih.gov/books/NBK1763/#CmdLineAppsManual.I43_Backwards_compatib. Newer versions of BLAST have only this wrapper script installed, and expect you to use the BLAST+ interface going forward.
I have found success using Bio::Tools::Run::StandAloneBlastPlus. The interface is very similar, and if your codebase is not very extensive yet, it should be relatively straightforward to begin using.

Resources