Skip to main content

Posts

Showing posts from April, 2014

Bash Script: apply color in text

We can use the following colors' codes: Black 0 ; 30 Dark Gray 1 ; 30 Blue 0 ; 34 Light Blue 1 ; 34 Green 0 ; 32 Light Green 1 ; 32 Cyan 0 ; 36 Light Cyan 1 ; 36 Red 0 ; 31 Light Red 1 ; 31 Purple 0 ; 35 Light Purple 1 ; 35 Brown / Orange 0 ; 33 Yellow 1 ; 33 Light Gray 0 ; 37 White 1 ; 37 And then use them like this in your script: red = '\e[0;31m' NC = '\e[0m' # No Color echo - e "${red}Hello Stackoverflow${NC}" Keep in mind you have to use '-e' after 'echo' and use double quote(") for text. Set Code Description Example Preview 1 Bold/Bright echo -e "Normal \e[1mBold" 2 Dim echo -e "Normal \e[2mDim" 4 Underlined echo -e "Normal \e[4mUnderlined" 5 Blink  1) echo -e "Normal \e[5mBlink" 7 Reverse (invert the foregro...

tomcat7 startup script (/etc/init.d)

#!/bin/bash # # chkconfig: - 80 20 # Tomcat 7 start/stop/status script # Forked from: https://gist.github.com/valotas/1000094 # @author: Miglen Evlogiev # # Release updates: # Updated method for gathering pid of the current proccess # Added usage of CATALINA_BASE # Added coloring and additional status # Added check for existence of the tomcat user # #Location of JAVA_HOME (bin files) export JAVA_HOME=/usr/java/default #Add Java binary files to PATH export PATH=$JAVA_HOME/bin:$PATH #CATALINA_HOME is the location of the bin files of Tomcat export CATALINA_HOME=/usr/tomcat/default #CATALINA_BASE is the location of the configuration files of this instance of Tomcat export CATALINA_BASE=/usr/tomcat/default #TOMCAT_USER is the default user of tomcat export TOMCAT_USER=tomcat #TOMCAT_USAGE is the message if this script is called without any options TOMCAT_USAGE="Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m...