Topic 1 - How to Solve a Technical Problem : Define the Problem

Having been around the block solving difficult technical computing and networking problems for over 4 decades, I find problem solving easy.

I am often amazed as unix.com members post questions looking for answers to problems where they do not understand the problem they are asking or demanding to be solved in a public forum.

Let's cut to the chase (come to the point) on this topic.

The first step in solving any problem is to define and understand the problem.

While statistics are often made up numbers, I would venture to guess that defining or understanding the problem is generally around 70 to 95% of the time required to solve a problem. Normally, if we know the problem, we can easily solve it. Finding out what the problem is often the hard part; the solution is generally easy when we know what the problem is.

So, when you have a computer problem, what helps define the problem?

Well, knowing what environment you are working in is key, right?

  • What is the operating system?
  • What is the version of the operating system?

It's is stunning how many people post questions on unix.com and completely omit to tell us this key fact in their first post.

Next, because we are working with unix-like systems here at unix.com; the user shell is also very important. Are you working in bash or sh or ksh for example? What version of the shell are you using.

One of the things which puzzles me is why people post shell script code without this information.

All shell script code, even code fragments, should be posted with a shebang. The shebang not only tells a computer what program is required to run the code, it quickly informs the human reader of the code as well. Humans are busy people with valuable time, no one should have to waste time when helping someone solve a computer problem guessing the OS, the shell and the versions. This is simply very basic information. Guessing is not necessary. When you post a problem, post the environment where your problem resides.

At a bare minimum, look at this example:

#!/bin/bash
echo "hello world"

Even in this very simple example, we have clearly identifed how we expect the computer to behave.

Look at this one:

#!/usr/bin/ruby
puts "hello world"

The same goes true here, we just told both the computer and the human reader what we expect from the computer.

So, at a minimum, check this example question out:

BEGIN EXAMPLE QUESTION

Hello Friends at this great community. Wow you guys are awesome!

I am working on the latest version of macos and cannot get this code to work:

#!/bin/bash
echo "hello world

When I run the code above in a file names a.sh, it dies with this error message:

macos$ bash ./a.sh
./a.sh: line 2: unexpected EOF while looking for matching `"'
./a.sh: line 3: syntax error: unexpected end of file

>

Why?

Thanks guys!

END EXAMPLE QUESTION

The point is that the fictitious person above posted a question and defined the OS (at least roughly, even though they neglected the version) and the shell and the provided the code they ran, how they ran it and the exact error message.

The problem has been defined pretty well, don't you think? It's not defined perfectly, but at least others know the basics of what is going on.

I will discuss the more in a follow-up post.

2 Likes