Thursday, November 1, 2012

How to find the number is Armstrong or not in Unix


#################################################
# To find the number is Armstrong or not                   #
#################################################

#!/bin/ksh
echo "This program is to find whether given number is Armstrong number or not”

# To make sure sufficient arguments
if [ $# -ne 1 ]
 then
   echo "Please provide one argument"
exit -1
fi

# Declaring and Assigning the values to the local variables
a=$1
s=0

# Logical part to find the Armstrong number
while [ $a -gt 0 ]
do
b=$(( $a%10 ))
s=$(( $s+$b*$b*$b ))
a=$(( $a/10 ))
done
if [ $s -eq $1 ]
then
 echo "The given number is the Armstrong number"
else
 echo "The given number is not Armstrong number"
fi
exit 0

How to find the sum of digits in the number in Unix


###########################################################
# To find the sum of digits in the number                 #
###########################################################

#!/bin/ksh

# Checking the required arguments
if [ $# -ne 1 ]
 then
   echo "Please provide one argument"
exit -1
fi

# assigning the arguments to the local variables
a=$1
s=0

# Logical part to find the sum of digits in the number
while [ $a -gt 0 ]
do
b=$(( $a%10 ))
s=$(( $s+$b ))
a=$(( $a/10 ))
done

echo "The sum of digits in $1 is $s"
exit 0

How to find whether string is palindrome or not in Unix


#############################################################
# To find whether the string is palindrome or not                                            #
#############################################################

#!/bin/ksh

# To make sure the sufficient arguments
if [ $# -ne 1 ]
then
  echo "Please enter one argument"
 exit -1
fi

# Declaring and assigning the values to the local variables
b=`echo $1 | wc -c `
c=$(( $b-1 ))
d=$(( $c/2 ))
flag=1
m=1

# Logical part to handle the palindrome calculations
while [ $m -le $d ]
do
    e=`echo $1 | cut  -c$c`
    f=`echo $1 | cut  -c$m`
    if [ $e != $f ]
      then
          flag=0
          break
    fi
     c=$(( $c-1 ))
     m=$(( $m+1 ))
done

  if [ flag -eq 0 ]
 then
echo "The string is not a palindrome"
else
echo "The string is palindrome"
fi
exit 0

Saturday, October 6, 2012

How to find the Largest and Smallest number in the given numbers in Unix


###############################################################
# To find the Largest and Smallest number in the given numbers      #
###############################################################

#!/bin/ksh

# To make sure sufficient arguments
if [ $# -ne 1 ]
then
  echo "Please provide the sufficient arguments"
  echo "bigsmall file_name"
  exit -1
fi

# Declaring and Assigning values to the local variables
set -A LIST `cat /clocal/fme/prod/forecast/padu/Lilly/numberlist.txt`
a=${#LIST[*]}
Small=${LIST[0]}
Big=${LIST[0]}

# Implementation of logic to find the biggest and smallest number
for i in ${LIST[*]}
do
 if [ $i -lt $Small ]
  then
  Small=$i
 elif [ $i -gt $Big ]
  then
  Big=$i
 fi
done
 echo "Smallest = $Small"
 echo "Biggest = $Big"

exit 0

How to find the biggest among 3 given numbers in Unix


##################################################################
# To find the biggest among 3 given numbers                                          #
##################################################################

#!/bin/ksh/

# To make sure sufficient arguments
if [ $# -ne 3 ]
then
echo "Please provide the three arguments"
exit -1
fi

# Declaring and assigning values to the local variables
A=$1
B=$2
C=$3

#Logical part to find the largest number among 3 numbers
if [ $A -gt $B  -a  $A -gt $C ]
   then
   echo "A $A is the biggest number"
        elif  [ $B -gt $A  -a  $B -gt $C ]
        then
        echo "B $B is the biggest number"
                elif  [ $C -gt $A -a  $C -gt $B ]
                then
                echo "C $C is the biggest number"

   elif  [ $A -eq $B -a $A -eq $C -a $B -eq $C -a  $C -eq $B ]
   then
  echo "All numbers are same"
fi

exit 0

Reverse the content in the file using Unix


#####################################################
# Reverse the content in the file                                       ##
#####################################################

#!/bin/ksh

# To make sure the sufficient arguments
if [ $# -ne 1 ]
then
  echo "Please enter the file name to be reverse"
  exit -1
fi

# Implementation of logic to reverse the content in the file
if [ -f $1 ]
  then
    rever=`rev $1`
 echo "Original file is"
 cat $1
 echo "Reverse of the file is"
 echo $rever
fi

exit 0

How to combine the files Vertically or Horizontally in Unix


########################################################
# Combine the files vertically or Horizontally                        ##
########################################################

#!/bin/ksh

# To make sure sufficient arguments
if [ $# -ne 2 ]
then
  echo "Please provide the two file names to be combine"
  exit -1
fi

# Initializing the local variables
file1=$1
file2=$2
Hori=/clocal/fme/prod/forecast/padu/Lilly/Horizontal.txt
verti=/clocal/fme/prod/forecast/padu/Lilly/Vertical.txt
echo "Please choose the combination format"
echo "1) Horizontal"
echo "2) Vertical"
read ch
case $ch in
1) cat $file1>$Hori
   cat $file2>>$Hori;;
2) paste $file1 $file2>$verti;;
*) ;;
esac
exit 0

How to display the alternative numbers in the given number in UNIX


##########################################################
# To display the alternative numbers in the given number         #
##########################################################

#!/bin/ksh

echo "Please enter one number"
read num
echo $num>temp.txt
i=1
len=`cat temp.txt|wc -c`

#Logic implementation

while [ $i -le $len ]
do
  alseries=`echo $num|cut -c $i`
  echo $alseries
i=`expr $i + 2`
done

rm -f temp.txt

exit 0

Tuesday, June 26, 2012

How to load the data using rule file in Essbase

In Essbase data can loaded into database in two ways:
                 Excel Lock & Sends.
                 Rule files.
Through Lock & Sends in excel data can be update/insert to the perticular combination of members.
Through rule file you can load the data file which consists bulk data.

Sunday, June 24, 2012

How build members in outline using rule file

Essbase outline is the hierarchical representation of the business system.
Outline has dimensions, members and attributes and many more.
Members, Attributes can be build using rule files even you can build the dimensions on the fly using rule file but this post covers how to build the members alone under the dimensions.

Friday, June 22, 2012

How to create an Outline in Essbase

In simple terms Essbase outline is hierarchical representation of the entire Business system.
It consists of Dimensions which are again categorized into two forms:
           Standard Dimension
           Attribute Dimension
Let's start simple journey to create the default outline

Tuesday, June 12, 2012

Small bug in Windows OS

I read one article in Computer Era Telugu edition last month about bugs in Windows OS.
This bug really caught my attention completely.

1) Open calculator application in the Windows OS.
2) Find the square root for 4 ( result will be 2)
3) Subtract the result from 2.
now check the result it will not be as you expected but it will be some other number.

Similarly check for the square root of 9 and subtract the result from 3 and check the result it will be some other value but not zero.

Thursday, April 26, 2012

How to copy directories alone from one directory to other


find . -type d  -depth | cpio -dumpl "Target directory path"
-depth : Always true. Causes descent of the directory hierarchy to  be  done  so  that  all entries in a directory are acted on before the directory  itself.   This  can  be useful  when  find  is  used  with cpio(1) to transfer files that are contained in directories without  write
permission.

cpio: copy files to or from archives.
Options : d : Creating a leading directories when needed.
              u : Unconditional
             m : preserve time, modifications
               l : link files
              p : In copy-out mode, cpio copies files into an archive. It reads a list of filenames, one per line, on the standard input, and writes the archive onto the standard output. A typical way to generate the list of filenames is with the find command; you should give find the -depth option to minimize problems with permissions on directories that are unreadable.
         

Why do elephants ears so big

The big ears are to help the elephants to stay cool, Elephants skin is very hard and it doesn't sweat, so to maintain the body heat elephants use their ears as Coolers, as at ears many of the blood vessels accumulated, there the exchange of heat taken place.

Saturday, April 21, 2012

My right mouse pop up no longer works in Excel?

When ESSBASE/Excel add-in is installed , the default behavior is for ESSBASE to "take over" your right mouse click.
This is because the Excel add-in provides for some additional ESSBASE functionality, the problem is that it is installed without your knowledge.
To regain the control of your right mouse pop up menu in Excel:

How fetch slice of data from one database to other database

We can fetch a slice of data from one database to other database using XREF function which intern using Location Aliases,
Here is small information how to use @XREF function in calculation script and Location Aliases in ESSBASE.

Thursday, April 19, 2012

How to do variance reporting in ESSBASE

Variance reporting property determines how ESSBASE calculates the difference between Actual and Budget data members,
The dimension should be tagged as Account then only variance reporting property becomes visible.
The member formula to calculate the variance reporting between Actual and Budget should consists either of @VAR or @VARPER
There are two types of variances
  •        Expense Reporting
  •        Non Expense Reporting.

Wednesday, April 18, 2012

What is Time Balance property in ESSBASE

Time Balance property is one of the hidden property in ESSBASE which comes into picture when you tag any dimension as a Accounts.
If an account dimension member uses the time balance property,it affects how ESSBASE calculates the parent of the member in Time dimension.
ESSBASE has three kind of TB properties:
  • TB First
  • TB Last
  • TB Average

Sunday, April 15, 2012

Know more about each file in ESSBASE

As soon as an application created in Essbase, the Analytical Services will creates different files such as Page file(.PAG), Index file (.IND) etc and each files stands for some specific purpose.
All these files are available at $ARBORPATH/app/application/database folder
.otn file (Outline file) : The files consists compile code for the outline hierarchy, member formula, Attributes and Aliases and others.

Sunday, April 1, 2012

Crazy bugs in Windows


Few bugs in windows which are funny and can't be explained by the Microsoft whole team, including Bill Gates!!!!!!

An Indian found that nobody can create a FOLDER anywhere on the Computer which can be named as "CON". This is something funny and inexplicable? At Microsoft the whole Team, couldn't answer why this happened! TRY IT NOW, IT WILL NOT CREATE A "CON" FOLDER

Saturday, March 31, 2012

Do you want to save time while creating reports in excel?


If your excel report consists the repeated data in many/all the sheets, don’t think about the copy and paste method we have something very interesting alternative.

Legacy way: Copy the required field and paste in all other required sheets.

Friday, March 30, 2012

How do I change the file access permissions in UNIX


Every file has following attributes:
Ø  owner's user ID ( 16 bit integer )
Ø  owner's group ID ( 16 bit integer )
Ø  File access mode word
'r w x -r w x- r w x' 
(user permission-group permission-others permission)
r-read, w-write, x-execute
To change the access mode, we use chmod(filename,mode).


Run the UNIX script on server


I wrote one UNIX script which eventually runs for hours together, which does much functionality fetching the data from DB2 tables and formatting and again loading into another tables. If I run the script in my local system by connecting to the client secured network (VPN) , I can’t guarantee the complete execution of the script.

My friend Maddy suggested me to run the script on server using nohup command in UNIX; here how it is

nohup script.cmd “environment variables” >script.cmd.out 2>&1 &


Comparison of DOS and Unix command-line interfaces

The DOS (Disk Operating System) and Unix environment are looking same in appearance but there are many differences, here are the few.

such as to list the directories and sub directories and hidden directories available in a drive we use ls -lRa in UNIX and we use dir/p/od in DOS environment .

Wednesday, March 28, 2012

Scope of variables in UNIX

To restrict the scope of variables to the function which it requires, we use typeset without any options, here is the example how to use the typeset without any functions to achieve the desired result in complex and large programs.


#!/bin/ksh/ 

x=1 
y=2 
function myfun { 
x=3 
typeset y=4 
print "Inside function x is $x" 
print "Inside function y is $y" 
} 
myfun 
print "Outside function x is $x" 
print "Outside function y is $y" 
exit 0   

Tuesday, March 27, 2012

How to record excel editing's in word document

Some times we need to create a word document which replicates the excel worksheet, there no need to create a table again and fill the data in word document, just do the below 

  •  Copy the required portion in excel template.
  • Open word document and choose paste special option in the paste sub menu item.
  • Select the Paste link radio button and select Microsoft Excel Worksheet Object, then click OK.



Now your word document keep updating as excel template updates.

Wednesday, March 21, 2012

Banned things in the countries


China banned Google instead they are using  www.baidu.com.
UK banned plasma TV.
Australia banned Laser pointers.
Cubes banned cell phones (restricted usage)
US banned ipod
Greece banned Google street views.
Germany banned Galaxy Tab
UAE and Saudi Arabia banned black berry.
Pakistan banned Facebook.
Israel banned ipad.

Sunday, March 18, 2012

Checking Arguments in Unix

Script with one argument to execute the further commands


if [ $# -ne 1 ]
then
   echo "Write your comments"
   exit -1 # exit the script
fi

$# stands for the number of arguments, it is number.
In if command you can change ne (not equal) to other comparing operator according to the requirements.
lt = Less than.
gt = Greater than.
le = Less than or equal.
ge = Greater than or equal.
eq= Equals.

Saturday, March 17, 2012

keyboard short keys

Few Keyboard shot keys to make work easier.
Open the Run command and type the given command to get the result.

%allusersprofile%                      = shows all users profiles.
%programfiles%                        = opens program files menu.
control desktop                          = opens desktop properties box.
osk                                               = onscreen keyboard.
pbrush                                         = paint.
regedit                                        = registry editor.
taskmgr                                      = task manager.
timedate.cpl                               = opens calendar.
write                                            = wordpad.
utilman                                        = utility manager.
winver                                         = windows version.
appwiz.cpl                                 = opens add/remove folder.
shutdown                                   = shut downs the system.
excel                                          = Microsoft Excel (If Installed)
msaccess                                 = Microsoft Access (If Installed)
powerpnt                                  = Microsoft PowerPoint (If Installed)
winword                                    = Microsoft Word (If Installed)
notepad                                    = Notepad
wordpad                                   = WordPad
calc                                           = Calculator
mspaint                                    = Microsoft Paint 



What is shebang in unix

The very first line in any UNIX shell script is shebang, Why should?
In UNIX the script is in Parent shell and the calculations will be done in child shell, in UNIX each shell has its own way of writing style, The script which we have right in our hands may or may not in that format, to make sure the parent shell execute calculations in the right child shell , we use she bang.
#!/bin/ksh (for korn shell)

Career path

Career path after 10,Plus two and Graduation

Why do most of the manholes are in circular shape

There are many reasons,
-> Very easy to manufacture compare to other shapes.
-> If water is flowing over to it , then it is capable of redirecting the water into tank or canal itself.
-> While closing the cap of manhole, just lift the cap perpendicular to the earth and turn it diagonal and leave, certainly it will not go in, but in other shapes it is possible.  

Windows notepad as Dairy

Few simple steps to create Dairy using Windows Notepad.
1) Open notepad.
2) Type .LOG (only .LOG)
3) Save the file with any valid name.
4) Close it and open
here is your Dairy