connection string is hardcoded


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting connection string is hardcoded
# 1  
Old 06-22-2009
connection string is hardcoded

Hi,

I have many perl scripts in single server, i am new to perl,

suggestions are appreciated.

connection string is hardcoded in all perl scripts
i need to make change the all perl scripts and there should be only one config file available in that server.

destination database is mysql

How i can achive this.

Thanks in advance.

Prakash GR

Last edited by prakash.gr; 06-22-2009 at 08:17 AM..
# 2  
Old 06-22-2009
Lots of information and examples out there on the Internet. Just search for "Perl configuration file"
# 3  
Old 06-22-2009
Hi,

Code:
use DBI;
use Mail::Sendmail;
use MIME::QuotedPrint;
use HTML::Entities;
use POSIX qw(strftime);

$localtime1 = strftime("%e-%b-%Y %I:%M %p",localtime(time));
$localtime2 = strftime("%Y-%m-%d",localtime(time));

#definition of variables
$db="crms";
$host="203.187.192.91";
$user="ccc";
$password="adminccc";  # the root password

#connect to MySQL database
my $dbhpindb   = DBI->connect ("DBI:mysql:database=$db:host=$host",
                           $user,
                           $password)
                           or die "Can't connect to database: $DBI::errstr\n";


if (!$dbhpindb)
 {
    print "Can not connect to the database!";
    die "";
 }
	

There are many .pl files are there where i need to use config file instead of variables.

Thanks

Prakash

Last edited by prakash.gr; 06-22-2009 at 03:24 PM..
# 4  
Old 06-29-2009
Hi,

any inputs.

Thanks
prakash
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX string connection to sql server db

Hi, i have to perform a connection from unix to sql server database, using TCP protocol. I have all connection parameters (user,pwd,server_name,port,db_name). How can i perform this connection, by unix console ? is it available a command similar to this one (for oracle): sqlplus... (1 Reply)
Discussion started by: nash83
1 Replies

2. Solaris

Encrypt a hardcoded passwd

hey guys, is there a way to encrypt a hard coded passwd inside a shell script basically this is my script and i was to encrypt or hide the ftp password. #!/bin/sh HOST='XXXXXXXXX' USER='XXXXXXXXXX' PASSWD='XXXXXXXXXXX' cd /tmp/ftptest grep -c "{0000000#END#\>" * > NO_OF_CARDS ftp -n... (1 Reply)
Discussion started by: q8devilish
1 Replies

3. UNIX for Advanced & Expert Users

How keep running a program n an another computer via a connection ssh when the connection is closed?

Hi everybody, I am running a program on a supercomputer via my personal computer through a ssh connection. My program take more than a day to run, so when I left work with my PC I stop the connection with the supercomputer and the program stop. I am wondering if someone know how I can manage... (2 Replies)
Discussion started by: TomTomGre
2 Replies

4. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

5. UNIX for Dummies Questions & Answers

Issue with use of Configuration file instead of hardcoded values inside the script

Hi, My code works perfectly fine. But, $my $min_to_add = 1 * 1 * 60; and my $hr_to_sub = 1 * 1 * 86400; i may need to change the values in future. so am keeping them in a separate configuration file like MIN = 1 * 1 * 60 HR = 24 * 60 * 60 in the script, i use a package use et_config... (3 Replies)
Discussion started by: irudayaraj
3 Replies

6. Shell Programming and Scripting

Database connection string

Hi, I am touching shell scripting after a long gap of 3 years and forgotten almost all of it. So need help from everyone to revamp myself. To begin,please tell me what does this part of script do ( I have been asked to go thru a script and get a feel of it): #get database connection... (1 Reply)
Discussion started by: agarwal
1 Replies

7. Solaris

Solaris 10 ftp connection problem (connection refused, connection timed out)

Hi everyone, I am hoping anyone of you could help me in this weird problem we have in 1 of our Solaris 10 servers. Lately, we have been having some ftp problems in this server. Though it can ping any server within the network, it seems that it can only ftp to a select few. For most servers, the... (4 Replies)
Discussion started by: labdakos
4 Replies

8. UNIX for Dummies Questions & Answers

how to enter hardcoded password automatically

In the script i am passing a command from script which is called from cron. When this command is called from cron the unix prompt asks for password. Can we automatically enter the password when promted(if the password is hardcoded in script)?? Please let me know how to enter the password... (4 Replies)
Discussion started by: abhi_n123
4 Replies

9. UNIX for Advanced & Expert Users

Connection reset by peer..closing connection

Hello I'm facing the above problem while doing a performance run. I've a script which I'm launching from my windows desktop using mozilla. The script will invoke backend action on a Solaris host which in turn feeds the records to a driver located on a linux box(Cent OS). What's happening is... (1 Reply)
Discussion started by: subramanyab
1 Replies

10. UNIX for Dummies Questions & Answers

ssh_exchange_identification: Connection closed by remote host Connection closed

Hi Everyone, Good day. Scenario: 2 unix servers -- A (SunOS) and B (AIX) I have an ftp script to sftp 30 files from A to B which happen almost instantaneously i.e 30 sftp's happen at the same time. Some of these sftp's fail with the following error: ssh_exchange_identification: Connection... (1 Reply)
Discussion started by: jeevan_fimare
1 Replies
Login or Register to Ask a Question