Getting String character by Character in bash

Sometimes you may need to get string character by character or need to looping through the string. In python programming language, you can do this job very easily.

See below example in python.

your_string="Hello"
for c in your_string :
        print (c)

This will give output as,

H
e
l
l
o


We can do same thing in bash shell scripting also,

see below bash shell scripting example.

#getting ord value of chars.
your_string="Hello"
echo $your_string | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | \
while read char
do
echo $char
done


Cheers.... ! Happy looping through the string !

Functions for ord and chr in bash shell scripting

In python there are couple of useful function. these are ord function and chr function.

ord function in python - it take character as an argument and return its ASCII value.

chr function - it takes integer values as an argument and returns character that is equivalent to the integer value.

I am going to introduce function to do same thing in bash shell scripting. I named it as ord.

ord() {

  LC_CTYPE=C printf '%d' "'$1"
  return $LC_CTYPE

}



My next function is chr function. it takes integer value as an argument and returns correspponding ASCII value.

chr() {
  [ "$1" -lt 256 ] || return 1
  printf "\\$(printf '%03o' "$1")"
}

My Life as a Systems Engineer

I am a Bsc. Engineering graduate in Computer Engineering who has acquired  expert knowledge in developing systems under Linux platform. I have gained 4+ years of experience in doing shell scripting, awk scripting, python, and java developing. I am professionally qualified in CCNA.

Working was fun as well as challenging day by day, where I invited most of the challenges to my life. Time to go to bed and time to wake was not according to the clock but according to the work which are pending or to find a new thing every day. It can be twelve clock in the midnight or twelve clock in the day time I was in front of the laptop programming code.


Freelance working has kept me in a high place which I took the membership in November having a good response rate, not cancelling any orders where my buyers has graduated me for Level 1.


Q6 : If you are the HRM of this company how can you prevent such scenarios?

See this post for Whole Question. 



Q6: If you are the HRM of this company how can you prevent such scenarios?

To achieve the set goals and objectives of the organization the human resources which play the major role in an organization should be managed and used in an efficient and effective way. Human resource management impact employee behavior, attitudes, performance, intelligent, skills and knowledge. The labor within the organization should be managed according to philosophies, politics, procedures and practices of Human Resource Management to get the maximized economic return from labor resources by decreasing the wastage of materials and equipment. The human resource management in an organization should be done by experts or a specially qualified person for benefits otherwise it will more lead to more strict rules and regulations and only managers people not thinking that the people are a resource which can be developed and trained to retrain for a long period of time which will be very advantageous for the company’s future. HR manage always make sure the workers that they are not doing a job but it is their own career and help them grow and develop by themselves.

The HR manager should be like honey in a Bee hive where all bees get together in making the Bee hive using honey and if there is anybody doing harm all the bees get together in protecting the Bee Hive. Likewise the workers will be willingly to work towards the productivity and future of the company when HRM is integrated into business strategy. The HR Manager should be fair to all employees at any level, cooperative and always should give a helping hand for the employees in their work. He should lead the workers administrate the internal functions such as checking the attendance of workers, organizing trainings depending the training needs of the organization. He should strategically win the good will of the employees and counsel workers. He should change systematically for different situations in order to maintain the flexibility for the employees to approach. If the HRM is not integrated property it will cause high rate of resignations within a short period of time.

The motivation and interest of the employees will be a poor the employees will criticize the organization always and there will be a loss in the output.

In the case study of MR. Kamal an effective and efficient HR Manager is the first person to realize the stress that which Kamal is undergoing. He is getting absent frequently and behavior has changed when working. As a first step the HR Manager discuss about this with Mr. Kamal and understand the situation of unwillingness to report the work. He will analyze the problem and arrive at conclusions to be discussed in three different aspects. One aspect is the Management and Mr. Kamal. He is facing difficulties with the policies, rules and regulations which newly introduced or weather he needs increments, bonus, promotion or an appreciation for his 20 years of service. HR Manager should understand which one of the following be the cause and must take immediate actions having discussions with the Management. Another aspect is the sub-ordinates of Mr. Kamal. Those who are in the same level as Mr. Kamal weather they are cooperative, team work or weather the juniors make troubles for him. The HR Manager can advise them informing about the situation of Mr. Kamal to be more friendly and polite to him. One the other hand may be he is unable to carry out the duties with the new technologies or else he needs special training to carry out work. So the responsibility of HR Manager is to send Mr. Kamal for suitable trainings so that he is conversant with his work. May be his change of position as for 20 years he was handling the same correspondence and it has become boring. So HR Manager can discuss with the managers and can help to look forward changing positions. If it is his mental ill health that he is facing the stress he can be granted some leaves to take SOME and come back to work with a refreshing mind.

Q5: How will the company react on Kamal’s behaviour?

See this post for Whole Question. 



Q5: How will the company react on Kamal’s behaviour?

The Reaction of the Company can be shown in two ways. One way which will be advantageous for Mr. Kamal to continue the work without stress and the other way company will take decisions in the punitive way which is disadvantageous for Mr. Kamal.

As Mr. Kamal has worked 20 years of long service, the company has a good image of his work. The management will question him and discuss the problems he is facing at this moment. This will lead to a mutual understanding between Mr. Kamal and the management and will get some relief for his stress. On the other way the managers will be able to understand and analyze the problem of this person who has worked for 20 years with no Job Stress and why he has suddenly undergoing such a thing. The managers who have similar type of experience will counsel him on reducing “Job Stress”, engage in activities to reduce the stress, manage the responsibilities so that work load get reduced and will remain some extra time to rest. The board of managers will analyze the cases for the stress weather it is a training need, change of position, physical ill health, too much workload salary increment or problems with sub-ordinates.

The management will take necessary actions for the problems that they feel that those are the causes for Mr. Kamal’s stress immediately for the future of Mr. Kamal as well as the company as under the clause that he was a being a faithful worker.

The behavior of Mr. Kamal may have been a problem to his department or the overall productivity of the company as he has been absent for no reason. The company will give 1st warning. 2nd warning with regard to absenteeism verbally or by writing. If he continues to do so a fine also can be charged or the salary will be deducted for the no of days absent.

They also can ask for a valid medical certificate prove his sickness which he cannot provide and they will make sure that it is by purpose that he has been absent and it will automatically convert to a disciplinary auction. If the productivity of the company also had been affected he will get the last warning can lead to compulsory leave transfer, demotion and stoppage of increment and promotion. If he had to undergo punishments as such his job stress will more increased and end up in a mental illness which cause to resign from the Job or the Company will terminate him due to ill health and under disciplinary actions. The interdiction can also be a punishment taken till the announcement the date to be present for the job. 

Q4 : What is the impact of Kamal’s thinking and behaviour on the productivity of the company he serve?

See this post for Whole Question. 

Q4: What is the impact of Kamal’s thinking and behaviour on the productivity of the company he serve?

It the case study Mr. Kamal he has been absent for two days pretending that he is sick and thinking of getting absent for few more days. Absenteeism affects the productivity of the company direct as the other employees have to do the work behalf of absent employee and it will be too much workload for him/her or else he/she has to continue shifts until he returns. When the work which need to be done by two persons is carried out by one person the work will be slow down and it can affect the daily targets of the company. When daily targets are not met automatically it will affect the productivity of the company. As Mr. Kamal hold the senior position his absent will hinder the work with stress during his working hours. So it will affect the other employees of the staff including the top management. The juniors cannot get any advice as he is stressed out and the will work on the way they wish and the work they do will not contribute the productivity of the company. The colleges will have a bad impression on him as he tend to use isolated and they will not help him in the work as  he is not friendly and cooperative as before. When working as a team if team spirit is lost finally it will affect the output as in this case the past which need to be handled by Mr. Kamal is not carried out until and had not work as a team the output cannot be achieved. The juniors will also try to follow him by the way it is not a good sign for them.

Productivity is the efficient and effective way of converting inputs into outputs. The inputs are the machinery, materials, equipment and labor. All these inputs had to be managed and used in a manner to get optimum use without wastage. The machinery need to be serviced, repair and has to be handled by trained personals to use properly. The materials need to be put in the right place at the right time and equipment should be used without any wastage. There by all these are controlled by labors.


Labor plays the major role in productivity of the company. Labor productivity is the fact which governs the productivity of the company. Labor can be categorized as unskilled, semi-skilled and skilled. It is advantageous for the company to make its labor trained and skilled in order to achieve the goals and objectives through productivity. Most of the companies are comparing productivity. Through facts and figures not by the achievements of labor productivity weather the goals and objectives set to labor. 

Q3 : What is the impact of Kamal’s thinking and behaviour on his family and children?

See this post for Whole Question. 


Q3: What is the impact of Kamal’s thinking and behaviour on his family and children?

Kamal’s thinking at this situation is to overcome the stress of Job Dissatisfaction. He has come to the level of thinking about resignation from the Job. The behavior of Mr. Kamal has an impact on his family and children due to the poor decisions made by him and his distressed well-being. Economically it will affect the family which may be they have to undergo a financial crisis if takes the decision of leaving the Job until he gets a new satisfied employment with a good remuneration. One day he will utilize all the leaves so that when there are no leaves to be utilized he will have to go for no pay leaves which results a deductions of the salary. It will affect the education of his children as he has no money to spend on children’s education. If he gets 3 medical leaves at a stretch he has to provide a valid medical certificate which he cannot provide because he took the leave for no reason. It will cause a problematic situation in the company and he will get more stressed out as it is to terminate from the job.

The behavior of Kamal affect interaction and relationship among the family members.
Parent-child Relationship – when Mr. Kamal is missing at the table every morning to take breakfast with the children. They feel uncomfortable and tend to think many things about this unnatural behavior. If they are small age children as they cannot understand the situation. Children will be sad.
Leadership – As the head of the family the children are in need of the leadership of their father and learn many things from their father’s behavior and they will get a bad impression on about their father.

Laughter – It is sad that laughter is a good mediation to overcome bad situations laughing together with the family members also can reduce stress. It is an essentiality within the family so that they may like to laugh together and share the happiness. But at this time they all will lose it.
Interaction between the family members Mr. Kamal has become isolated from the family. When the interaction among family members are hindered not only him but them also get depressed.
Communication – Not everybody in the family are mind ready so he need to communicate the situation he faces so that others can understand him better and help him to overcome stress.
If he continue work along with stress it will affect his family in the same way. It is said that “stress makes people angry” so at home he will get angry for slightest and other family members also suffer with the same capacity.


Relation between Husband and Wife – The Relationship between Husband and wife is broken in the situation as Mr. Kamal tend to take poor decision by himself and will be in a stressful mood all the time. 

Q2: How it (1 above) affects Kamal’s Job Satisfaction and his decision?

See this post for Whole Question.

Answer for Q1

Q2: Job Satisfaction

Job Satisfaction can be simply defined as “weather an individual is content with the job he does” Locke (1976) defined Job Satisfaction as “A pleasurable or positive emotional state resulting from the appraisal of one’s job or job experiences”. Also he forwarded a theory called “Range of affect Theory” or the “Job Satisfaction Model”. The theory describes the connection between the one who has the job. Furthermore how much value is given to the Job. The dispositional approach was proposed by Thomothy A. Judge, Edwin A. Locke and Cathy C by “Core self-evaluations Model” Which says that Job Satisfaction is governed by an Individual. Another theory put forward with “Equity Theory” which shows and other workers. As a summary according to many researches job satisfaction is an emotional well-being which is governed by an individual which has an effect on equality between employer and other workers. The factors which influence the job satisfaction are as follows.
Increasing cooperation between the workers organizing trips, functions, outing to create the feeling of “one family” between the workers and employer.
Develop Career – Having training to develop the weaknesses of the employees and helping of the higher studies/courses.

Introducing Technology – By introducing new technologies among workers which in turn make working easier.

Highly qualified HR Manager – Having a highly qualified HR manager in the work place to discuss the problems faced by employees and HR Manager should understand strategically. Solve the problems.
Relationship With Co-workers – when the person is happy cooperative and helpful with his/her co-workers.

Relationship with superiors/Management – When a person is satisfied with the decisions taken by the management the rules and regulations and the way their immediate superiors handle them.
Working Environment – Pleasant working environment with all the necessary facilities attract the employees to work with an interest.

Equality – Treating all the employees equally irrespective of their levels (Executive, Junior, Labor ) and allowing the employees to understand that each and every person is important for the running of the company.
Security of the Employment – When the employee are on temporary or contract basis they are always on doubt when will they can be terminated by the employment so tend to search by the opportunities or more secure jobs. If the employees are permanent they are satisfied with the employment.
Self-Motivation – Giving good remuneration, increments, attractive bonus, annual bonus as the employees are very much concern about the money that they receive.

Interest – Some employees might do a job which he/she has no interest of doing but in the sake of earning money or any other reason they are performing the responsibilities such employees should be identified by the company and should give a job they wish.
Job dissatisfaction occur with all the factors listed above are not met by the employee and the Company. Depending on the emotions, personality and mentality of the person are one of these factors will make the job dissatisfied for any Employees.
In the case Study Mr. Kamal gets up in the morning thinking about the stressful working day and planning to get absent without any responsible cause. It shows that he is dissatisfied with the job he does. It can be the influence of any factors listed above. As he had served for the company may be he expected to get a promotion. Salary increment or an award in recognition of his 20 years of service. He says that the work is hard and boredom may be that he has lost the interest due to working on the same thing for a long period. He is in need of a change of position or a change in the working environments. He thinks that working in this company is a waste of time for the reason that his career has not being enhanced by the company though trainings and experiencing. Whereas within the working environment he has not being treated well or fairly compared to other employees in his level.
On account he is at the stage of job stress and poor decision making by the cause of “Job Dissatisfaction”

Decision Making is taking actions based on the objectives and goals of an individual to be achieved or people make certain decisions to overcome problems, stressfulness. Decision Making is interdependent on many factors such as personality, attitudes, education, emotions, time and the situation. A decision taken at a stressful situation vary from decision taken at a calm situation. Decision taken at this time will be completely different in 20 years’ time. As Mr. Kamal is in a situation of “Job Dissatisfaction” his decisions can be not correct or cause problematic situations to himself, company and his family. He has taken the decision of getting absent which will give more stress to him with 2 days’ workload and when the productivity gets slow down there can be issues with the management resulting deductions in the salary which affect his family.

Draw basic shapes in turtle package in Python

I am going to demonstrate on  how draw basic geometric shapes using turtle package of python. First of  all the turtle package should be installed. Then we need to import turtle package into your python script.

Use the given below command.

import turtle

Turtle package is ready to use. Now you need to create object in Turtle.

turtle = Turtle()

Turtle is like a pen in your hand. Therefore you need to lift the pen to draw something. Use following command. to to up the pen.

turtle.up()

Move your pen to desired position. you need to define the place where your pen moves to.

turtle.goto(0,0)

I moved my pen to (0,0) coordinate. Now I am ready to draw something using my turtle pen. Now I am going to draw straight line. I am starting my line from point (0,0) and ending my line at point (100,100)

turtle.goto(100,100)

Then I need to tell my turtle pen to down to my canvas.

turtle.down()

Before drawing I need to set my pen width. I set my pen width to 5.

turtle.width(width=5)

Draw Straight line,

#!/usr/bin/python

import turtle
turtle = turtle.Turtle () turtle.up() turtle.goto(0,0) turtle.down () turtle.goto(100.,100) turtle.width(10

Now We can Draw simple circle.  To draw a circle we need starting point as well as radius. I am going to use following set of commands to draw circle.

#!/usr/bin/python

import turtle

turtle = turtle.Turtle ()

turtle.up() turtle.goto(0,0) turtle.down () turtle.circle(100) turtle.width(10)
I need to fill my Circle with Blue colour and line colour should be black.

#!/usr/bin/python

import turtle
turtle = turtle.Turtle ()
turtle.up() turtle.color("black","blue") turtle.goto(0,0) turtle.begin_fill() turtle.down () turtle.circle(100) turtle.width(10) turtle.end_fill()

begin_fill and end_fill functions are used to start and end fillings.


Draw rectrangle in turtle.

#!/usr/bin/python

import turtle

turtle = turtle.Turtle ()
turtle.color("blue") # line colour turtle.up() turtle.goto(0,0) # starting point turtle.down() turtle.forward(90) turtle.right(90) turtle.forward(100) # length of rectrangle turtle.right(90) turtle.forward(90) turtle.right(90) turtle.forward(100) # width of rectrangle


forward function is used to move pen forward to specific distance and right function is used to turn pen to right side by given angle . As well as there is left functions also. It used to turn your pen to left side by given angle.

#!/usr/bin/python

import turtle

turtle = turtle.Turtle ()
turtle.color("blue") # line colour turtle.up() turtle.goto(0,0) # starting point turtle.down() turtle.forward(200) turtle.left(120) turtle.forward(200) turtle.left(120) turtle.forward(200) turn.left(120)


Now you can draw basic shapes using turtle graphics. Try to draw complex figures !

Cheers !!!





Converting raw_input to input from python 3.0

The raw_input function is not in used after python 3.0 . raw_input function has been replaced by input function.

raw_input function is used for getting user inputs. This function mostly used in python 2.7

Now this function is replaced.

Both input and raw_input functions are belongs to sys package. Therefore sys package should import to your python script.

import sys


See below Example for usage of this function.

 your_input = input ("Please Type Something :")


Not only the raw_input function.

print command also converted into a function. To print something on the python shell, type following command.

print ("Hello World !");