bash – expand shell variables ( bash bug resolved )

2015-08-17 1 min read Bash

As you would have noticed in the recent versions of bash, expansion does not work properly when expanding directory names. So, for something like this

cd $varname

if you press tab, then variable name does not expand properly.

If this is something that is bothering you then you can now add the following in your bashrc and revert to older behaviour:

shopt -s direxpand

Hope this helps you.

ShellCheck – check basic POSIX shell script errors

2015-08-03 1 min read Bash Fedora

Here is description of the tool:

Description : The goals of ShellCheck are:
  • To point out and clarify typical beginner’s syntax issues,
    :   that causes a shell to give cryptic error messages.
  • To point out and clarify typical intermediate level semantic
    :   problems, that causes a shell to behave strangely and
    :   counter-intuitively.
  • To point out subtle caveats, corner cases and pitfalls, that may
    :   cause an advanced user’s otherwise working script to fail under
    :   future circumstances.

To install

Continue reading

Debuggging bash cron scripts.

2014-09-01 1 min read Bash Learning

I have to several times debug scripts that I get complain about working when logging in normally but they do not work when run in cron mode. So, quite a lot of times, redirecting the stderr of the script is all that is required to see what is happening, but sometimes that just does not help if the script is calling another script which is mis-behaving and under lot of other conditions. So, how to at-least take a look at why these are failing, login with ssh.

Continue reading

ldap search function

2014-08-25 2 min read Bash Learning

First you will need the ldap search utility. The client for ldap search comes in openldap-clients, so you need to install that first:

sudo yum install openldap-clients

Now, that you have installed it, try to find something in some open ldap server, example:

ldapsearch -LLL -h  db.debian.org   -x  -b "dc=debian,dc=org" "cn=Joao*"

This should list couple of entries for you. Now, that you have ldapsearch working, lets define a function in .bashrc file:

Continue reading
Older posts Newer posts