As I wrote in bash-shell-prompt, you can use $PS1 environment variable to make bash do valuable things. Now I find that the other variable $PROMPT_COMMAND can do a similar task.
Recently I began to use FreeBSD 4.11, cause bash is not FreeBSD’s default shell, it is not well configured in FreeBSD. For one thing, when I use putty to login to it, the window title is static, displaying whatever I set in putty’s preference. This is not the case with Red Hat Linux. I want to get the feature working on FreeBSD, after some searching I found $PROMPT_COMMAND is the point. Just copy its value from Linux box then FreeBSD works the same.
If you happen to use FreeBSD with bash, I recommend you set $PROMPT_COMMAND to the following value
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"
just add the following to your .bashrc would do
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'.
bash’s $PROMPT_COMMAND Saturday, Aug 11 2007
Uncategorized 7:22 pm
startup/shutdown oracle automatically on el4.5 Monday, Jul 30 2007
Uncategorized 2:24 pm
Google search got this page: http://www.orafaq.com/forum/t/52084/0/
But paste the dbora file to my machine, there are some problems:
1. chkconfig --add dbora complaining “service dbora does not support chkconfig”
2. lsnrctl start/stop failed
After some investigation, I’ve solved the problems. The first one is to add the chkconfig comment(with the dbora and description lines), the second is to export the ORACLE_HOME(not ORA_HOME) and ORACLE_SID variables, and to remove the “-”s in “su” commands. Below is my version of dbora:
#!/bin/bash
# dbora Oracle auto start-stop script.
# chkconfig: 345 99 10
# description: Oracle database
# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME from which you wish to
# execute dbstart and dbshut;
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORACLE_HOME.
# Set ORACLE_SID to the sid of your database.
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1/
ORACLE_SID=luol
ORA_OWNER=oracle
export ORACLE_HOME ORACLE_SID
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNER -c $ORACLE_HOME/bin/dbstart
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su $ORA_OWNER -c $ORACLE_HOME/bin/dbshut
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/dbora
;;
esac
To use it just copy it to your /etc/init.d/dbora file, change the relevant variables’ value, chmod, chkconfig --add dbora. You should also check to see if you need to edit you /etc/oratab file.
And everything would work fine as mine. Hopefully…
Note: If you’re in a locale other than English, when you copy & paste the file content from browser to your computer, you may get corrupted quote marks, if you have problem running the script, make sure the quote marks in your file is correct.
The following are my scripts, you can download it for use. The ‘doc’ extension is just used to prevent wordpress from blocking my upload, you can change the extension or delete it.
isqlplus startup script
oracle database startup script
Bash shell prompt Sunday, Jul 22 2007
Uncategorized 8:51 pm
Bash shell prompt, which is the famous $PS1 variable’s value. After some improvements I’m using this value
'\[\a\033[30;47m\]\u@\h \[\033[32m\]\W\[\033[30m\]\$\[\033[0m\]'
(excluding the single quotes, of course) right now.
Some notes: This will let the shell beep(if your machine has a speaker, and the driver — module pcspkr — is correctly loaded) every time the prompt comes out(when the command you executed is finished), this is very handy for long running commands, you can issue a command, read some blogs(or doing anything you like), when the command done it will inform you with the beep, so no need to “wait and just watch the screen”. Colorful prompt(I guess no body — at least not many — still use some terminal which can’t display text with color) is a great help when dealing with long page by page command output, so you can scroll the output and easily find your command line(because they are colorful, not black and white).
My original PS1 used to have \es within it, but I’ve replaced them with \033s. This is to avoid a problem which will occur with some versions of bash(or maybe nothing about bash, just the whole software environment causes the problem): when typing long(more than half a line), after some point you will see that the characters you keep entering goes half-way back to the beginning of the line, overwriting the characters you entered before, the command can just be run with no problem, just a little strange and not so comfort when typing. The $PS1 value I posted above have been tested with CentOS 4.5, FreeBSD 4.11 with bash 3 installed, hopefully it will successfully be used with other environment. I’d like to hear from you about the “portability” of PS1, and surely, if you have a better prompt value to share.
For the question “how to change the PS1 value on my machine”, I’d recommend you read some other article, there’s plenty of them, for example:
http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-2.html
Use EL4.5 to replace CentOS 5 Monday, Jul 16 2007
Tonight I installed Oracle’s Unbreakable Enterprise Linux 4.5, on the machine which was originally running CentOS 5. This machine is mainly used for development, especially when one Linux machine(the other one) is not enough for doing something. So I’d like to tell it as a “backup”. But it is more powful in the sense that it is a physical machine where the other is installed on a vmware server.
CentOS 5(actually maybe I would say RHEL 5) has some little “problem”, as per my favor. Some of these are: SELinux is too stricted that I can’t easily use swat to config samba for a simple share. Oracle database is not supported on this new system(which was my main reason to choose Oracle EL but not CentOS 4.5, I guess EL would be more happy with Oracle 10g).
Before CentOS 5 I mainly used CentOS 4.2(besides Windows), at the time I tried to switch to 5, I was somewhat frustrated about 4.2 cannot making a fast mount to Windows shares(there always delay when trying to mount with smbmount, or even worse is that mount -t cifs would crash the whole system), and the mount cannot handle Chinese file names. CentOS 5 hasn’t any of these problems, which made me exciting some time.
Nevertheless, with EL 4.5 the problems are gone too. I can mount -t cifs with no delay, and the Chinese file names are handled well. As version 5 of the OS is much new, with some parts not so mature than the long lasting version 4, and I’m much more confortable with my well known older version, I’d like to choose the latter.
Choosing EL 4.5 also helps coordinating my whole Linux development environment. The two machines aforementioned would be better working together when they are “wearing the same clothes”.
TODO: This is one of the many times that I do the same thing: Starting the PXE server side, doing some config stuff, sitting at the target machine, power on and hit DELETE to make it booting from lan, then waiting for the config screen to show up, config, waiting for packages to be unpacked … many waiting, and many times there would be something that is not working the way it should be, so have to reconfig and rewait…
So this time I use the kickstart for automatic installation. But that is not enough, it’s best that I can make some useful thing(probably using shell script) that can automatically make my freshly installed machine configured to my own flavor(such as color & beep in PS1), when time permitted, I would try to do this.
NetBeans5.5.1 english locale with Chinese characters displayed Monday, Jul 16 2007
Uncategorized 1:26 pm
There are some Chinese NetBeans Users who prefer to use NetBeans with English locale when his OS is Chinese. The simplest solution is to add “-Duser.language=en” to the jvm parameter, but NetBeans 5.5.1 seems not having a convenient way to add jvm parameter(such as providing some config file).
After Googling a lot I found that I can add “–locale en” to NetBeans’ startup shortcut command. This maybe is the “official” way to change a locale. But only with this added is not perfect, there are some UI element that remains to be Chinese even when most part of the UI is in English, where in this situation the Chinese characters just get messed up.
Incidentally, I found that changing the Look and Feel of NetBeans to Metal would give a workaround to the problem above. So the entire solution is to change the shortcut’s target from
"E:\Program Files\netbeans-5.5.1\bin\netbeans.exe"
to
"E:\Program Files\netbeans-5.5.1\bin\netbeans.exe" --locale en --laf javax.swing.plaf.metal.MetalLookAndFeel
where you should change the location of netbeans.exe to your own installation location.
screenshot:
First things to do Saturday, Jul 14 2007
TODO 4:14 pm
Using shortcuts to manage different locations on hdd(disks/partitions/network shares), also in Linux
Left-handers maybe more efficient in dealing with keyboard and mouse
Write a shell script or C application to handle the backup of files in the web publish directory of a development server
Dual screen for E-book reading and practice
Emacs settings and shell prompt
First day on COMFORT Saturday, Jul 14 2007
Diary 4:02 pm
Long before I found my self pursuing comfort a lot. But not until some days before did I have an idea to put my experiences to a blog, what a pity! Nevertheless, I eventually have this blog started!
Next week there are three final tests which are my headaches, so the new born blog maybe hang for some time.
Comphert, at the beginning. Saturday, Jul 14 2007
Uncategorized 3:45 pm
A blog about comfort(syntax error?). Mainly on how to use computer with comfort.
Just like many guys working with computer everyday, I enjoy thinking hard about how to improve my experiences on this. From training myself using mouse left-handedly, to writing some small shell script to get routine work done faster. I admit that the effort spent on this maybe bigger than the advantages I got, but I just enjoy doing this…
I wanna share my own “tricks” on this topic with folks of the same interest, or even better, to attract more people to enjoy comfort. Hope this can be done, and your help is greatly appreciated!
