Problem with `cat` the compiled output of C program in unix

Hello All,

I have coded a C program which looks something like below... (program name: test.c)

#include<stdio.h>
main()
{
int dist,dm,dcm;
printf(" Enter the distance between 2 cities in KM : ");
scanf("%d",&dist);
dm=dist*1000;
dcm=dist*10;
printf("Distance between 2 cities in Meter is %d \n",dm);
printf("Distance between 2 cities in centi-meters is %d \n",dcm);
return 0;
}

when compile this in unix by using the below command

 cc test.c 

I will get the compiled output as a.out which i need to give to my team members...
Now My problem is....! If someone by mistake try to see what is there inside the a.out by using cat a.out
it will start to BEEP and will not stop for while... I dont want this to happen... it should just show the weird language inside the a.out file without any sound....how can i do that?

Thank you.
Regards,
smarty86.

---------- Post updated at 06:59 AM ---------- Previous update was at 05:54 AM ----------

And also one more thing I'm using HP-UX m/c.. so zip is not working in that..

is there any other way to zip in HP-UX m/c?

team members?

are you people geting paid?

try

compress a.out
# later on
uncompress a.out.Z

Why don't you just send the C code to your friends -- ? Let them compile.

whatever.. even if they compile and then they do cat of the compiled file the same thing happens... i dont want that BEEP to come... so.. please help me

The beeps are generated by the console/terminal emulation, trying to interpret the bytes output by cat. cat faithfully prints whatever is in the file. The file is a collection of opcodes, which you can't change unless you switch to a different architecture, but even then there'll be codes that will make your system beep.

In short: unless your colleagues run (not available on every UNIX)

setterm -blength 0

first, outputting the compiled code will almost always beep.

Off topic. Beware of calling a program "test". It is the name of a unix command.
Maybe tell your colleagues about the "file" command which will tell them whether a file is "text" and therefore suitable for reading with "cat".
The beep usually comes from a byte containing Hex 07 - meaning a terminal bell character in a text file (which program object code isn't).

I lol'd hard at this :slight_smile: