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?
like this
# 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:
Or like this?
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.
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
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 )
$ sqlplS myuser@PRODUCTION_DB
...........
...............
regards
ygemici