alias setting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting alias setting
# 1  
Old 03-02-2012
alias setting

I want to set an alias to connect to sqlplus and also run a command while it it logs in.
How can I do that?
# 2  
Old 03-02-2012
like this
Code:
# alias sql_='sqlplus|tee sql.log'
#
# sql_

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Mar 2 15:03:51 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Enter user-name:

# cat sql.log

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Mar 2 15:03:51 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Enter user-name:

# 3  
Old 03-02-2012
Or like this?

Code:
alias runsql='sqlplus /NOLOG @programname.sql'

This assumes that your login environment is suitable for running "sqlplus" and that programname.sql contains a suitable "connect" command.
# 4  
Old 03-05-2012
Sorry, but my intention was different.
Say I have several putty windows opened. Now I want that when I connect to production database , then the font color changes to red.
Now I can write an alias in shell to do that, but how do I write an alias that will connect to production database and run my shell program so that the SQL font color changes to red.
# 5  
Old 03-05-2012
Quote:
Originally Posted by som.nitk
Sorry, but my intention was different.
Say I have several putty windows opened. Now I want that when I connect to production database , then the font color changes to red.
Now I can write an alias in shell to do that, but how do I write an alias that will connect to production database and run my shell program so that the SQL font color changes to red.
add this to your ~/.bash_profile
Code:
sqlplS () {
if [ $(echo "${1#*@}"|grep -w PRODUCTION_STRING) ] ; then
echo -en "\\033[1;31m" && sqlplus $1 && echo -en "\\033[0;39m"
else
sqlplus $1
fi
}

( change to "PRODUCTION_STRING" to real_production_db_string in tns )

Code:
$ sqlplS myuser@PRODUCTION_DB
...........
...............

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting alias (quotes, acutes)

Hello, I'd like to have an alias to view some processes sorted: I have:ps -ef | grep pmon | awk -F" " '{ print $8" "$0 }' | sort | cut -d" " -f2- | grep -v "grep pmon" It doesn't work, however, if I put it as alias because on acutes insize awk:alias pmon='ps -ef | grep pmon | awk -F" " '{ print... (4 Replies)
Discussion started by: JackK
4 Replies

2. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies

3. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

4. UNIX for Dummies Questions & Answers

Setting alias with echoing embedded $ sign

I tried to set up some alias in my .profile to save typing. One of the alais i tried to set up is alais test='echo 123$acct54679abc' But when I typed in test in the command line. The echo only dispaly 123 and truncated all the string starting from the $ sign. Is there any way to display the... (6 Replies)
Discussion started by: oht
6 Replies

5. Shell Programming and Scripting

Setting alias for a user - Linux ubuntu

Hi i have a user "SYSTEM" i want to set the below command in his .profile for an alias: who | awk '{print $1}'| sed '/SYSTEM/d' | sed '/root/d' |xargs -i pkill -u {} i tried as below: alias stop = " who | awk '{print $1}'| sed '/SYSTEM/d' | sed '/root/d' |xargs -i pkill -u {}" ... (3 Replies)
Discussion started by: joycesolomon
3 Replies

6. Solaris

Alias setting in Solaris

Hi All, I need some information on 'Alias' setting in SUN SOLARIS.:confused: Q1. I want to know how can i set my alias here. Q2. How to view all set 'ALIAS' for me. (say /home/jdash user) Q3. Can i modify the set 'Alias' for me or for whole environment. Q4. Is Alias setting can be change... (2 Replies)
Discussion started by: jdash.ps
2 Replies

7. Red Hat

Setting an alias in Redhat

Hi Everyone, I am trying to set up alias the only way I now how, buy making entry into .bashrc file. The entry I made is alias ll='ls -lrt' It is not working as I expect. When I enter "alias" at the command line I get the following. $ alias alias l.='ls -d .* --color=tty' alias... (2 Replies)
Discussion started by: jxh461
2 Replies

8. Shell Programming and Scripting

please help me regarding alias

Dear All, I have given alias to run a script which will calculate memory and cpu utilization as "utils" in my bash shell. Even i have given this entry in .profile and .bashrc in my home directory. It is working fine. Now my question is that I want to use this alias in... (17 Replies)
Discussion started by: naree
17 Replies

9. UNIX for Dummies Questions & Answers

Query regarding alias and setting bash as a default script

Hi All, I am setting bash as my working shell in my .profile file. So I have written a line : bash as the list line in my .profile I want to use alias as follows: alias me='who am i' When i log in, as expeced I enter the bash shell but alias doesn't work. Is it because the alias is defined... (1 Reply)
Discussion started by: VENC22
1 Replies

10. UNIX for Dummies Questions & Answers

Setting a boot device alias on Sun hardware

I watched this done a long time ago, but cannot find it anywhere. I need to alias the boot device "disk" to /sbus@7,0/QLGC,isp@0,10000/sd@c,0 I think I need to set "use-nvramrc?" to true, and then create an alias within the nvramrc to point disk to the boot disk, but this is the step I cannot... (3 Replies)
Discussion started by: 98_1LE
3 Replies
Login or Register to Ask a Question