Correct Bash and shell script variable capitalization

By convention, environment variables (PAGER, EDITOR, …) and internal shell variables (SHELL, BASH_VERSION, …) are capitalized. All other variable names should be lower case. Remember that variable names are case-sensitive; this convention avoids accidentally overriding environmental and internal variables. Keeping to this convention, you can rest assured that you don’t need to know every environment … Read more

Error handling in Bash [closed]

Use a trap! tempfiles=( ) cleanup() { rm -f “${tempfiles[@]}” } trap cleanup 0 error() { local parent_lineno=”$1″ local message=”$2″ local code=”${3:-1}” if [[ -n “$message” ]] ; then echo “Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}” else echo “Error on or near line ${parent_lineno}; exiting with status ${code}” fi exit … Read more

How can I ssh directly to a particular directory?

You can do the following: ssh -t xxx.xxx.xxx.xxx “cd /directory_wanted ; bash –login” This way, you will get a login shell right on the directory_wanted. Explanation -t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)