Linux

Parse query string in shell script

Sometimes we have to integrate multiple languages like node.js/php/shell script into bash shell script and parse query string to array for supplying query string data for manipulation.

Here is the simple script which will help you to achieve that goal:

#!/usr/bin/env bash
declare -A querydict
populate_querystring_array () {
query=”$1″
while IFS== read arg value
do
querydict[“$arg”]=”$value”
done < <(echo “$query” | sed ‘s/&/\n/g’ )
}

q=’user=mindgeek&password=1234f’
populate_querystring_array “$q”
printf “${querydict[user]}\n”

Read More...

Linux

How to configure libstdc++ with GCC 4.8?

You need to tell your dynamic linker (it’s executed when you run your program) where to find the library. Set LD_LIBRARY_PATH to the path of the library (probably somewhere under /app/gcc/4.8.0/lib or something).

Use find /app/gcc/4.8.0 -name “libstdc++.so.6”. Add the directory to your LD_LIBRARY_PATH. e.g with the path I mentioned:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/gcc/4.8.0/lib (if you’re using a bourne-like shell which the default on Linux).

Then try to run your program.

Voila!!

Read More...