Skip to main content

Posts

Showing posts from 2016

How to DUMP dataset to a flat file in Datastage ?

This can actually be found on ibm website : http://www-01.ibm.com/support/docview.wss?uid=swg21625028 $ cd /app/ibm/InformationServer/Server/DSEngine/ $ . ./dsenv $ export APT_CONFIG_FILE=/app/ibm/InformationServer/Server/Configurations/default.apt $ $APT_ORCHHOME/bin/orchadmin dump -delim '|' sample_dataset.ds > sample_dataset.txt In the above example the DSEngine location my vary depending on your installation path.

How to extract prefix or suffix on a unix string

Sometime you are processing a lot files and you have to construct a dynamic prefix and suffix based file names. So you can search for multiple files based on prefix pattern and suffix pattern. Here's how you extract the PREFIX of a string given you have some sort of delimiter in the string itself. bash-4.1$ echo "THISPREFIX_blahblah_yyymmdd.txt" THISPREFIX_blahblah_yyymmdd.txt bash-4.1$ var123="THISPREFIX_blahblah_yyymmdd.txt"; file_prefix=" ${var123%%_*} " ; echo $file_prefix THISPREFIX bash-4.1$ In the above example string what we want to extract are the charcters after the _ (underscore) thus in our variable manipulation we specified _ after the %% which denotes that we get all the characters before _. So for the SUFFIX extraction the patter is similar only we use ## instead of %%. see below : bash-4.1$ echo "THISPREFIX_blahblah_yyymmdd.txt" THISPREFIX_blahblah_yyymmdd.txt bash-4.1$ var123="THISPREFIX_bla

how to create dynamic variable in unix ?

This is a problem where in you a have a config file and you have wrapper script and a child script where in your wrapper and child script are generic enough to process certain task depending on the parameter you pass to create your dynamic variable and source your static value from a config file, this way you wouldn't need to touch your scripts but only the config. I found a lot of ways through googling easiest would be the bash solution but fortunately i am using ksh so another one was the use of eval, however most of the solutions i found using eval on the net didn't work for me, either i didn't know how to use or apply it, so i tried a few combinations and below is what worked for me : If your doing it in bash shell its quite easy : dev_config_var=abc;  dynamic_value=dev;  dynamic_var=${dynamic_value}_config_var;   echo ${!dynamic_var} so you see the trick if you are in bash is just "!". but if we are doing in ksh, then its a different story.