Install cobol compiler

Hi

I dont have a cobol compiler in my redhhat linux box, and so I want to install it. When i try the below command

sudo apt-get install open-cobol

it tells "apt-get : command not found". I tried to find apt-get under my root, could not find it anywhere.

Should we install apt-get also? If so, how?

RHEL has yum instead of apt-get.

yum install open-cobol

Hi Verdepollo
When I tried it, yum is also not there in my system. It tells command not found for yum as well.

When I did a find for the yum command under root, it found one under /etc/log.d/scripts/services. Is this the one? Looks like a small perl script. When i ran it it is just waiting for some user input?

Please advice.

Yeah, now I see it's not RHEL but Red Hat Linux (which version?).

If you have a RHN subscription you can download rpm-get (apt-get) from their website.

Or you can get open-cobol source files and build it yourself (you will also need libltdl and libgmp) - OpenCOBOL - InstallGuide

Hi.

If you can change Linux distributions, see post #7 http://www.unix.com/programming/151366-cobol-compiler-suse.html\#post302484450

However, as verdepollo writes, open-cobol can be compiled and installed. To test this, I installed it on CentOS and tested it with:

#!/usr/bin/env bash

# @(#) s1	Demonstrate COBOL compile and execute.

# Section 1, setup, pre-solution.
# Infrastructure details, environment, commands for forum posts. 
# Uncomment export command to test script as external user.
# export PATH="/usr/local/bin:/usr/bin:/bin"
set +o nounset
pe() { for i;do printf "%s" "$i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
C=$HOME/bin/context && [ -f $C ] && . $C specimen cobc
set -o nounset
pe

# FILE=${1-data1}
FILE=${1-hello,world.cobol}

# Section 2, display input file.
# Display sample of data file, with head & tail as a last resort.
pe " || start [ first:middle:last ]"
specimen $FILE \
|| { pe "(head/tail)"; head -n 5 $FILE; pe " ||"; tail -n 5 $FILE; }
pe " || end"

# Section 3, solution.
pl " Results:"
set +o nounset
if [ -n "$LD_LIBRARY_PATH" ]
then
  export LD_LIBRARY_PATH="$LD_LIBRARY_PATH /usr/local/lib"
else
  export LD_LIBRARY_PATH="/usr/local/lib"
fi
pe " (debug cobol install: COBOL is $(whereis cobc))"
pe " (debug cobol install: LD_LIBRARY_PATH is :$LD_LIBRARY_PATH:)"

cobc -x -free hello,world.cobol
./hello,world

exit 0

producing:

$ ./s1

Environment: LC_ALL = C, LANG = en_US.UTF-8
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.18-194.26.1.el5, i686
Distribution        : CentOS release 5.5 (Final)
GNU bash 3.2.25
specimen (local) 1.17
cobc (OpenCOBOL) 1.0.0

 || start [ first:middle:last ]
Whole: 5:0:5 of 6 lines in file "hello,world.cobol"
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
MAIN.
   DISPLAY 'Hello, world from open-cobol.'.
   STOP RUN.
 || end

-----
 Results:
 (debug cobol install: COBOL is cobc: /usr/local/bin/cobc)
 (debug cobol install: LD_LIBRARY_PATH is :/usr/local/lib:)
Hello, world from open-cobol.

The CentOS 5.5 is the free version of RHEL 5.5.

The install went smoothly, they provided more than 150 tests -- all passed.

There is another COBOL at SourceForge, TinyCOBOL. It appears to be more recently modified, but I could not get it installed (I only tried briefly).

Good luck ... cheers, drl