- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to connect to database in shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2002 11:44 PM
тАО03-21-2002 11:44 PM
how to connect to database in shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2002 11:47 PM
тАО03-21-2002 11:47 PM
Re: how to connect to database in shell script
please would you could tell us what type of database and release.
cheers
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2002 11:50 PM
тАО03-21-2002 11:50 PM
Re: how to connect to database in shell script
If this is oracle we are talking this would be a way (there's several other ways) :
#!/bin/ksh
sql_logon=$1
sql_script=$2
$ORACLE_HOME/bin/sqlplus << !! 2>&1 >tgd008.log
$sql_logon
@$sql_script;
quit
!!
Hope this helps,
Tom Geudens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2002 12:06 AM
тАО03-22-2002 12:06 AM
Re: how to connect to database in shell script
#!/usr/bin/ksh
isql
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-22-2002 12:30 AM
тАО03-22-2002 12:30 AM
Re: how to connect to database in shell script
for oracle
sqlplus << EOF
select * from tab;
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2002 04:39 AM
тАО03-27-2002 04:39 AM
Re: how to connect to database in shell script
Here is what you need :
1. Remote database
#sqlplus userName/passWord@OracleInstance<
select ....
insert ....
delete ....
update ....
EOD
The name "OracleInstance" is the name of the oracle instance defined in the file tnsnames.ora
2.Local database
#sqlplus userName/passWord<
select ....
insert ....
delete ....
update ....
EOD
HTH
Magdi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2002 05:02 AM
тАО03-27-2002 05:02 AM
Re: how to connect to database in shell script
use strict;
use DBI;
my $dbh = DBI->connect( 'dbi:Oracle:orcl',
'jeffrey',
'jeffspassword',
{
RaiseError => 1,
AutoCommit => 0
}
) || die "Database connection not made: $DBI::errstr";
my $sql = qq{ CREATE TABLE employees ( id INTEGER NOT NULL,
name VARCHAR2(128),
title VARCHAR2(128),
phone CHAR(8)
) };
$dbh->do( $sql );
$dbh->disconnect();
http://www.saturn5.com/~jwb/dbi-examples.html
live free or die
harry