some scripting from advanced shell scripting