Skip to content
Advertisement

Cannot Connect to Linux Oracle Databse with Perl Script after connecting with PuTTY

I have the following problem:

I currently connect to one of our Linux servers using PuTTY on my Windows 10 machine. If I use a ‘standard’ PuTTY connection I have no problem: I can log in and run my Perl script to access an Oracle database on the Linux server. However, recently I have set up a new PuTTY connection (I copied the original working copy used above). The only difference from the original is that I have entered the following in the section Connection->SSH->Remote command of the PuTTY configuration window:

cd ../home/code/project1/scripts/perl ; /bin/bash

(I have done this so I arrive directly in the folder containing all my scripts.)

I can still log into the server with no problems and it takes me straight to the folder that contains my Perl scripts. However, when I run the script to access the Oracle database I get the following error:

DBI connect('server1/dbname','username',...) failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var  or PATH (Windows) and or NLS settings, permissions, etc. at PerlDBFile1.pl line 10.
impossible de se connecter à server1 / dbname at PerlDBFile1.pl line 10, <DATA> line 1.

In addition, if I run the env command on the server the variable $ORACLE_HOME is not listed (If I run the same env command on the server with the standard PuTTY connection the $ORACLE_HOME variable is present.)

Just to note: Running any other Perl script on the server (that does NOT access the Oracle database) through either of the PuTTY sessions I have created works with no problems.

Any help much appreciated.

Advertisement

Answer

OK, I have the solution!…Thanks to everyone who replied.

Basically, I originally had the command:

cd ../home/code/project1/scripts/perl ; /bin/bash (See original post)

To get it to work I replaced the above with

cd ../home/code/project1/scripts/perl; source ~/.bash_profile; /bin/bash

I also tried:

cd ../home/code/project1/scripts/perl; /bin/bash; source ~/.bash_profile

But that did NOT work.

Hope this helps someone.

Gauss76

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement