Sponsored Content
Top Forums Shell Programming and Scripting How to connect to Oracle database using shell script? Post 302732853 by pmotewar on Monday 19th of November 2012 09:30:32 AM
Old 11-19-2012
How to connect to Oracle database using shell script?

Hi All,
I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect.

I have tried like below,
Code:
cnt=`sqlplus -s /nolog << EOFSQL  
              connect $USER/$PASS@$DB
		SET pagesize 0 feedback off verify off heading off echo off
			select COUNT(1) from dual;
		exit;
		EOFSQL`

I am fetching username , password and DB name from parameter file.

Please help me.

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by vbe; 11-19-2012 at 11:34 AM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Connect to sybase database using Korn shell script

Hi, Can anyone please give me a script or let me know how to connect to a sybase database and execute a query using Korn shell scripts.Am new to Unix but i need to do this ASAP. Please help. Thanks, Gops (7 Replies)
Discussion started by: bhgopi
7 Replies

2. Shell Programming and Scripting

How to connect to database db2 through Unix Shell Script

I am trying to connect to database db2 through shell script. The process I am trying is > db2 It gives me error Access Denied. While checking for access I have the rights. Is there ant other way round..? Please help. (3 Replies)
Discussion started by: ankitgupta
3 Replies

3. Shell Programming and Scripting

how will i connect postgres database from unix shell script

I have got the solution so just closing this issue. (3 Replies)
Discussion started by: jambesh
3 Replies

4. UNIX for Dummies Questions & Answers

Shell scripting+connect to oracle database+spooling

Hi! Everyone I am new to the shell scripting basically.I have been asked to create a shell script that connect to a oracle database to read data from a particular schema then spool it into a csv file then email to customer. Can anybody let me know how to go about that. I have create... (14 Replies)
Discussion started by: Mr Mo
14 Replies

5. Shell Programming and Scripting

How to connect with oracle database using unix...

Hi all I am working in datawarehouse project and use DB2 database . shell scripting is written to connect with DB2 database in my application but i dont know how to connect with oracle databse or other databases.Is there any command in unix to connect any of these datbases? (6 Replies)
Discussion started by: vijays3
6 Replies

6. Shell Programming and Scripting

Connect to oracle db using shell script

Hi, I want to connect to oracle db using unix shell script. And i want to retrieve data from db through shell script. Please help me as soon as possible. Thanks, J.P. Das (1 Reply)
Discussion started by: jyotidas
1 Replies

7. Shell Programming and Scripting

Korn Script to connect and query oracle database

I've been sent the following script to finish. It's supposed to connect to an oracle database, query it, and send an email if the query result value is one or more. Currently it isn't connecting properly, just giving the following error: ERROR: ORA-01017: invalid username/password; logon denied... (2 Replies)
Discussion started by: jackmorgan2007
2 Replies

8. Shell Programming and Scripting

Shell Script to connect to the oracle database

Hi Unix Gurus, I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
Discussion started by: bshivali
8 Replies

9. UNIX and Linux Applications

Identify a specific environment Oracle variable to connect a remote Oracle database ?

Good evening I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus. I tried to find out the user/passwd and service name by env variable and all Ive got is this: ORACLE_SID_REPCOL=SCL_REPCOL ORACLE_SID=xmeta ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Discussion started by: alexcol
2 Replies

10. Shell Programming and Scripting

Connect to Oracle database

could someone please help me in shell scripting. i want to connect to oracle database which is on remote sever. requirement: 1 want to check files in source directory if file exist then a execute a corresponding batch jobs on unix sever and fetch data from oracle database which is on remote... (2 Replies)
Discussion started by: refi123
2 Replies
CREATEUSER(1)						  PostgreSQL Client Applications					     CREATEUSER(1)

NAME
createuser - define a new PostgreSQL user account SYNOPSIS
createuser [ options... ] [ username ] DESCRIPTION
createuser creates a new PostgreSQL user. Only superusers (users with usesuper set in the pg_shadow table) can create new PostgreSQL users, so createuser must be invoked by someone who can connect as a PostgreSQL superuser. Being a superuser also implies the ability to bypass access permission checks within the database, so superuserdom should not be granted lightly. createuser is a shell script wrapper around the SQL command CREATE USER [create_user(7)] via the PostgreSQL interactive terminal psql(1). Thus, there is nothing special about creating users via this or other methods. This means that the psql application must be found by the script and that a database server must be running at the targeted host. Also, any default settings and environment variables used by psql and the libpq front-end library will apply. OPTIONS
createuser accepts the following command-line arguments: username Specifies the name of the PostgreSQL user to be created. This name must be unique among all PostgreSQL users. -a --adduser The new user is allowed to create other users. (Note: Actually, this makes the new user a superuser. The option is poorly named.) -A --no-adduser The new user is not allowed to create other users (i.e., the new user is a regular user, not a superuser). -d --createdb The new user is allowed to create databases. -D --no-createdb The new user is not allowed to create databases. -e --echo Echo the queries that createuser generates and sends to the server. -E --encrypted Encrypts the user's password stored in the database. If not specified, the default is used. -i uid --sysid uid Allows you to pick a non-default user ID for the new user. This is not necessary, but some people like it. -N --unencrypted Does not encrypt the user's password stored in the database. If not specified, the default is used. -P --pwprompt If given, createuser will issue a prompt for the password of the new user. This is not necessary if you do not plan on using pass- word authentication. -q --quiet Do not display a response. You will be prompted for a name and other missing information if it is not specified on the command line. createuser also accepts the following command-line arguments for connection parameters: -h host --host host Specifies the host name of the machine on which the server is running. If host begins with a slash, it is used as the directory for the Unix domain socket. -p port --port port Specifies the Internet TCP/IP port or local Unix domain socket file extension on which the server is listening for connections. -U username --username username User name to connect as (not the user name to create) -W --password Force password prompt (to connect to the server, not for the password of the new user). ENVIRONMENT
PGHOST PGPORT PGUSER Default connection parameters DIAGNOSTICS
CREATE USER All is well. createuser: creation of user "username" failed Something went wrong. The user was not created. If there is an error condition, the backend error message will be displayed. See CREATE USER [create_user(7)] and psql(1) for possibili- ties. EXAMPLES
To create a user joe on the default database server: $ createuser joe Is the new user allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n CREATE USER To create the same user joe using the server on host eden, port 5000, avoiding the prompts and taking a look at the underlying query: $ createuser -p 5000 -h eden -D -A -e joe CREATE USER "joe" NOCREATEDB NOCREATEUSER CREATE USER SEE ALSO
dropuser(1), CREATE USER [create_user(7)] Application 2002-11-22 CREATEUSER(1)
All times are GMT -4. The time now is 02:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy