Cobol Hello World on Fedora 18

I’ve been thinking about learning Cobol programming for awhile. I figured I would pull out my rusty old book, “REA’s Problem Solvers Computer Science”, since it is the only reference book that I have to Cobol.

Figured I would first get a Cobol compiler installed. So..


# yum search cobol
Loaded plugins: langpacks, presto, refresh-packagekit
updates/pkgtags | 333 B 00:00:00
============================================= N/S Matched: cobol =============================================
open-cobol.x86_64 : OpenCOBOL - COBOL compiler
libcob.i686 : OpenCOBOL runtime library
libcob.x86_64 : OpenCOBOL runtime library

Well, this looks promising…


# yum install open-cobol
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package open-cobol.x86_64 0:1.1-0.20090209.fc17.2 will be installed
--> Processing Dependency: libcob = 1.1 for package: open-cobol-1.1-0.20090209.fc17.2.x86_64
--> Processing Dependency: gmp-devel >= 4.1.4 for package: open-cobol-1.1-0.20090209.fc17.2.x86_64
--> Processing Dependency: libcob.so.1()(64bit) for package: open-cobol-1.1-0.20090209.fc17.2.x86_64
--> Running transaction check
---> Package gmp-devel.x86_64 1:5.0.5-3.fc18 will be installed
---> Package libcob.x86_64 0:1.1-0.20090209.fc17.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
open-cobol x86_64 1.1-0.20090209.fc17.2 fedora 220 k
Installing for dependencies:
gmp-devel x86_64 1:5.0.5-3.fc18 fedora 175 k
libcob x86_64 1.1-0.20090209.fc17.2 fedora 85 k

Transaction Summary
==============================================================================================================
Install 1 Package (+2 Dependent packages)

Total download size: 480 k
Installed size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): gmp-devel-5.0.5-3.fc18.x86_64.rpm | 175 kB 00:00:00
(2/3): libcob-1.1-0.20090209.fc17.2.x86_64.rpm | 85 kB 00:00:01
(3/3): open-cobol-1.1-0.20090209.fc17.2.x86_64.rpm | 220 kB 00:00:01
--------------------------------------------------------------------------------------------------------------
Total 342 kB/s | 480 kB 00:01
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:gmp-devel-5.0.5-3.fc18.x86_64 1/3
Installing : libcob-1.1-0.20090209.fc17.2.x86_64 2/3
Installing : open-cobol-1.1-0.20090209.fc17.2.x86_64 3/3
Verifying : open-cobol-1.1-0.20090209.fc17.2.x86_64 1/3
Verifying : libcob-1.1-0.20090209.fc17.2.x86_64 2/3
Verifying : 1:gmp-devel-5.0.5-3.fc18.x86_64 3/3

Installed:
open-cobol.x86_64 0:1.1-0.20090209.fc17.2

Dependency Installed:
gmp-devel.x86_64 1:5.0.5-3.fc18 libcob.x86_64 0:1.1-0.20090209.fc17.2

Complete!

Great, this looks awesome! Okay, now how to use it?


man -k cobol
cobol: nothing appropriate.

Um…?


$ o
obconf oldrdist openssl os-prober
obex-data-server on_ac_power openvpn osx
objcopy onsgmls openvt ownership
objdump onto2vocabularyclass orbd oxygen-demo
obxprop open orc-bugreport oxygen-gtk3-demo
oclock openal-info osd_login oxygen-gtk-demo
od openbox osgmlnorm oxygen-settings
oggconvert openbox-lxde ospam oxygen-shadow-demo
okular openbox-session ospcat
oldfind openconnect ospent

Um…?


$ co
cobc colormgr command consolehelper-gtk coproc
cob-config colrm compgen console-kit-daemon core_server.py
cobcrun column complete consoletype
col combinedeltarpm compopt continue
colcrt comm consolehelper convertquota

Ummm…?


man -k cob
cobblerd_selinux (8) - Security Enhanced Linux Policy for the cobblerd processes
httpd_cobbler_script_selinux (8) - Security Enhanced Linux Policy for the httpd_cobbler_script processes
Tcl_RegExpExecObj (3) - Pattern matching with regular expressions

Ummm..?


$ co
cobc colormgr command consolehelper-gtk coproc
cob-config colrm compgen console-kit-daemon core_server.py
cobcrun column complete consoletype
col combinedeltarpm compopt continue
colcrt comm consolehelper convertquota

Oh, that looks like it might be it.


cobc --help
Usage: cobc [options] file...

Options:
--help Display this message
--version, -V Display compiler version
-v Display the programs invoked by the compiler
-x Build an executable program
-m Build a dynamically loadable module (default)
-std= Compile for a specific dialect :
cobol2002 Cobol 2002
cobol85 Cobol 85
ibm IBM Compatible
mvs MVS Compatible
bs2000 BS2000 Compatible
mf Micro Focus Compatible
default When not specified
See config/default.conf and config/*.conf
-free Use free source format
-fixed Use fixed source format (default)
-O, -O2, -Os Enable optimization
-g Produce debugging information in the output
-debug Enable all run-time error checking
-o Place the output into
-b Combine all input files into a single
dynamically loadable module
-E Preprocess only; do not compile, assemble or link
-C Translation only; convert COBOL to C
-S Compile only; output assembly file
-c Compile and assemble, but do not link
-t Generate and place a program listing into
-I Add to copybook search path
-L Add to library search path
-l Link the library -D Pass to the C compiler
-conf= User defined dialect configuration - See -std=
--list-reserved Display all reserved words
-save-temps Do not delete intermediate files
-MT Set target file used in dependency list
-MF Place dependency list into
-ext Add default file extension

-Wall Enable all warnings
-Wobsolete Warn if obsolete features are used
-Warchaic Warn if archaic features are used
-Wredefinition Warn incompatible redefinition of data items
-Wconstant Warn inconsistent constant
-Wparentheses Warn lack of parentheses around AND within OR
-Wstrict-typing Warn type mismatch strictly
-Wimplicit-define Warn implicitly defined data items
-Wcall-params Warn non 01/77 items for CALL params (NOT set with -Wall)
-Wcolumn-overflow Warn text after column 72 (FIXED format, NOT set with -Wall)
-Wterminator Warn lack of scope terminator (END-XXX, NOT set with -Wall)
-Wtruncate Warn possible field truncation (NOT set with -Wall)

-ftrace Generate trace code (Executed SECTION/PARAGRAPH)
-ftraceall Generate trace code (Executed SECTION/PARAGRAPH/STATEMENTS)
-fsyntax-only Syntax error checking only; don't emit any output
-fdebugging-line Enable debugging lines ('D' in indicator column)
-fsource-location Generate source location code (Turned on by -debug or -g)
-fimplicit-init Do automatic initialization of the Cobol runtime system
-fstatic-linkage Statically allocate non-USING LINKAGE parameters
-fsign-ascii Numeric display sign ASCII (Default on ASCII machines)
-fsign-ebcdic Numeric display sign EBCDIC (Default on EBCDIC machines)
-fstack-check PERFORM stack checking (Turned on by -debug or -g)
-ffold-copy-lower Fold COPY subject to lower case (Default no transformation)
-ffold-copy-upper Fold COPY subject to upper case (Default no transformation)
-fnotrunc Do not truncate binary fields according to PIC (ala MF)
-fnull-param Pass extra NULL terminating pointers on CALL statements

That looks like it, but still… um…?


$ man cobc
No manual entry for cobc

I’m starting to get a little annoyed now.


info cobc
...Nothing...

Okay, let us start off by checking out the OpenCOBOL website hello world page.

So, I start out writing my program.


IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.

Now compile.


$ cobc -x hello.cob
hello.cob:1: Error: Invalid indicator 'I' at column 7

What? I thought I just copied and pasted stuff! After reading the doc a bit more, it becomes obvious. The cryptic message, “The I of IDENTIFICATION must be at the column 8 ( 7 spaces before ).”, really means, put 7 spaces before each line. Now this is starting to feel like Python…

Okay, so fix some spacing.


IDENTIFICATION DIVISION.
PROGAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!"
STOP RUN.

And compile


$ cobc -x hello.cob
hello.cob:2: Error: syntax error, unexpected "Identifier", expecting "PROGRAM-ID"

Awww, snap. I didn’t copy and paste. PROGAM-ID != PROGRAM-ID. So fix some code.


IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!"
STOP RUN.

And finally…


$ cobc -x hello.cob
In file included from /usr/include/stdio.h:27:0,
from /tmp/cob3740_0.c:6:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
/usr/bin/ld: cannot find -lncurses
/usr/bin/ld: cannot find -ldb
collect2: error: ld returned 1 exit status

Oh, come on! Fine…


# yum install ncurses-devel
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.9-7.20121017.fc18 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
ncurses-devel x86_64 5.9-7.20121017.fc18 fedora 708 k

Transaction Summary
==============================================================================================================
Install 1 Package

Total download size: 708 k
Installed size: 2.1 M
Is this ok [y/N]: u
Is this ok [y/N]: y
Downloading Packages:
ncurses-devel-5.9-7.20121017.fc18.x86_64.rpm | 708 kB 00:00:01
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ncurses-devel-5.9-7.20121017.fc18.x86_64 1/1
Verifying : ncurses-devel-5.9-7.20121017.fc18.x86_64 1/1

Installed:
ncurses-devel.x86_64 0:5.9-7.20121017.fc18

Complete!

Okay, try again.


$ cobc -x hello.cob
In file included from /usr/include/stdio.h:27:0,
from /tmp/cob3928_0.c:6:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
/usr/bin/ld: cannot find -ldb
collect2: error: ld returned 1 exit status

Do some googling….


# yum install libdb-devel
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package libdb-devel.x86_64 0:5.3.21-3.fc18 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
libdb-devel x86_64 5.3.21-3.fc18 fedora 36 k

Transaction Summary
==============================================================================================================
Install 1 Package

Total download size: 36 k
Installed size: 126 k
Is this ok [y/N]: y
Downloading Packages:
libdb-devel-5.3.21-3.fc18.x86_64.rpm | 36 kB 00:00:00
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libdb-devel-5.3.21-3.fc18.x86_64 1/1
Verifying : libdb-devel-5.3.21-3.fc18.x86_64 1/1

Installed:
libdb-devel.x86_64 0:5.3.21-3.fc18

Complete!

One more try!


$ cobc -x hello.cob
In file included from /usr/include/stdio.h:27:0,
from /tmp/cob4020_0.c:6:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]

Hurrah! Just one nasty warning. We’ll ignore that for now.


$ ./hello
Hello World!

Isn’t it beautiful?

-Kim

How Pre-Paid Cell Phone Service Sucks and How Regulation Isn’t Helping

I’ve recently been using T-Mobile prepaid plans for my cell phone service. I am surprised and disappointed in the industry as a whole for the prepaid service.

My first encounter with how customers are treated differently was while I was purchasing a prepaid cell phone. I went into the T-Mobile store to purchase my phone. After looking around and having great help with the sales agent, I made a purchase by handing him my VISA card. After receiving my receipt I went home.

After using my phone for a day or two, I received a call on my cell phone stating that if I didn’t pay for my phone that I would have my service discontinued. I had to go back in and pay for my phone to continue to receive service.

I went into the T-Mobile store to pay for my cell phone again. Before I could talk to the manager or sales agent about my cell phone that I hadn’t paid for, I had to wait in line for over an hour. After talking to the manager about why I hadn’t paid for my phone, it was determined that the sales agent had pushed the wrong button, and that this happens all the time because of the layout of the sales system. I asked the manager if this could be fixed, to which he replied “Good luck!”. He indicated that the T-Mobile store was a big company, and that change wasn’t going to happen.

I asked the manager if I could get a credit for my troubles, to which the manager said, of course not. You’re a prepaid customer. There is nothing I can do for you because you aren’t a loyal customer. Since one of my purposes with going with a a prepaid plan is to avoiding having a contract, T-Mobile automatically assumes that you aren’t a loyal customer. I left the store fuming mad at T-Mobile. I figured I would let the issue drop though, and it had left my mind up until recently.

With my wife and I still using T-Mobile service as a “Loyal” pre-paid customers, we recently checked our pre-paid T-Mobile balance. My wife, who typically uses $10.00 a month, had suddenly used $80.00 in a single month. We figured it would be a simple check of her call history or text history. Her cell phone logs didn’t show anything of interest. Next we figured we would check the call history on T-Mobile’s website. No luck. We couldn’t find a call history or any idea what the $80.00 went towards.

As a last resort we got ahold of support. Support wouldn’t tell us anything about our history.

We aren’t the only ones:

“we do not apply regulatory fee for prepaid users. If we will apply billing and payment history, prepaid customers will be required to pay the regulatory fee like postpaid users.”

http://support.t-mobile.com/message/188505?tstart=0

I believe that our regulations should encourage accountability of phone companies, not discourage it.

T-Mobile, I am disappointed in you. Federal Government, I am disappointed in you. I don’t think fees and regulations that discourage accountability of big corporations are good for our country.

-Kim

My Windows 8 Review

Okay,

I will be honest. I haven’t installed Windows 8. I haven’t used it; and this story is mostly about Windows 7.

Today, I got home from work, pulled out my laptop; and then I pushed the little button to turn my laptop on. I was greeted by the usual Windows 7 bootup. Then out of the darkness arose a great beast. The password screen. I waved my keyboard of might and magic and typed like you’ve never seen a password typed before.

Once the password was written, the spinning thing you see while waiting for Windows to load appeared in the page of doom. It just pretty much hung there; until it Windows 7 has made me loose my patience. Windows 7 is now dead, being replaced by the mighty keyboard of truth and justice, Linux.

Long story short, Windows 8 will be just about as good as 7. An expensive doorstop for Linux. Linux sure isn’t free with the time and effort needed to use it, but it sure is a lot cheaper than the incantations Windows needs to keep running.

Kim

My wife gets her license!

This last month has been a great event in Ham Radio history for my family. After months of study, my wife finally attempted to take the Ham Radio test.

She only missed two questions!

We are anxiously awaiting for her radio to arrive. We are getting her an ICOM-T7H. Most of my family who are Hams have the same radio. The goal is to have all of us have the same radio so that we can easily help each other out.

-Kim

Sleepless

I’m not normally an early morning type of person, but for some reason I was up this morning at 3:00 AM. I’ve been up since, and I’ve just arrived into the office.

Of course, I think part of the problem is that I’ve started to go to bed earlier. Last night I was in bed by 9:00 PM. This is rather unusual, as for most of my life, I haven’t gotten to bed until around eleven or twelve.

Anyone else sleepless tonight?

-Kim

Rebuilt website

I’ve finally rebuilt my website using WordPress. This time I built my site using child themes. See this.

I am not sure this is always a good idea though. For example, if you build your site off of another theme, and that them is updated, it could potentially break the functionality of your site.

Using child themes may work best in the case that you are selling the themes. It would be an easy way to build a single theme with the base functionality, and then provide add-ons themes to that theme. As far as modifying the themes, it can start to become a puzzle of where do I to make this modification or that modification.

I think in some cases, using a child theme can be helpful, but at the same time, it could be healthier to just keep all the files together. What are your thoughts?

-Kim

Migrating Hosts Day

Today is host migration day. I’ve been migrating off of a VPS to shared hosting. The main goal is to give myself more time to work on projects, and less time managing the webserver.

We’ll see how everything goes. I’ve got one site setup so far. Only many to go.

I’ve been doing some work with Hadoop Mapreduce lately. The thing I find odd about the model is the lack of pause/resume/recovery. Correct me if I am wrong, but I just don’t see any support for this type of behavior.

-Kim

Kernel.org gets hacked

If you haven’t noticed, but kernel.org got hacked recently. Security is a rather interesting topic. I believe that most, if not all systems are hackable.

Reason systems are hackable:

-Software is flawed. All software is flawed because people are flawed. Computers today usually contain millions of lines of code to help people perform simple tasks. In those millions of lines of code, there can be all sorts of potential flaws a hacker could exploit. An example is the Playstation 3 USB hack. (http://en.wikipedia.org/wiki/George_Hotz)

-People are flawed. Evan if you have software that is perfect, you can usually convince people to do something stupid. Take Kevin Mitnick for example(http://en.wikipedia.org/wiki/Kevin_Mitnick). Most of his hacks were social networking hacks.

In the end, I think it is important to remember that we are not secure. Things are going to get stolen, and we should have a plan B. In the case of Kernel.org, they had a plan B. Git was a distributed source control system, so it didn’t matter if someone nuked their servers, they had copies of the source control all over the place.

-Kim

Spanish Web Site

I have a Spanish blog that I am trying to keep. Well, it is more about learning about Spanish.

It has taught me how to add the ñ to a url. That was fun. You can learn more by going here. Typing with a spanish layout is sometimes difficult because of all the changes.

You can check the site by going here.

-Kim