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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with `cat` the compiled output of C program in unix
# 1  
Old 11-26-2009
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)

Code:
#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
Code:
 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?
# 2  
Old 11-26-2009
team members?

are you people geting paid?
# 3  
Old 11-26-2009
try
Code:
compress a.out
# later on
uncompress a.out.Z

Why don't you just send the C code to your friends -- ? Let them compile.
# 4  
Old 11-26-2009
Quote:
Originally Posted by jim mcnamara
try
Code:
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
# 5  
Old 11-26-2009
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)
Code:
setterm -blength 0

first, outputting the compiled code will almost always beep.
# 6  
Old 11-26-2009
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).
# 7  
Old 11-27-2009
Quote:
Originally Posted by bigearsbilly
team members?

are you people geting paid?

I lol'd hard at this ^_^
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Run program compiled in Ubuntu in centos

Will a program compiled in ubuntu 14.04 execute in Centos 7? That is to say a tarball or zip is downloaded from github and extracted, compiled, and make is all done in ubuntu 14.04, can I mv the program from ubuntu 14.04 to Centos 7, add it to path in Centos 7. And run it? Thank you :) (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Getting output from a file similar to cat output

I have a file # cat /root/llll 11 22 33 44 When I cat this file content to a variable inside a shell script and echo that shell script, it does not show up as separate lines. I need echo output similar to cat. cat /root/shell_script.sh #!/bin/bash var=`cat /root/llll` echo $var (2 Replies)
Discussion started by: anil510
2 Replies

3. Programming

Using ANSI color codes in gcc compiled program

I have put some yellow color codes and works well. I call the funstion using print_usage(stderr, 0); I would like to know if there is any way, to store the ansi color codes in variables and then call them inside fprintf. Or have a format followed by the strings I want to output. ... (5 Replies)
Discussion started by: kristinu
5 Replies

4. Solaris

Issue in pro*C program compiled in solaris 10

Hi, We upgraded our servers from solaris 9 to 10. We recompiled all the Pro*C programs with the new oracle version as well. Oracle is 11g. We are facing core dump with the below error for certain executions. But when we are placing new statements between the error fucntion we get junk values to... (1 Reply)
Discussion started by: saroopkris85
1 Replies

5. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

6. UNIX for Dummies Questions & Answers

Making a program compiled on Unix (HPUX) work on Linux

I am trying to make an application which works on unix to work on linux. I already tried copying the binary files and start it up but I am getting an error stating "Cannot execute binary file". Then I tried to recompile but i am getting an error whenever I tried to recompile. I am getting the... (1 Reply)
Discussion started by: khestoi
1 Replies

7. Programming

Storing the output of a Unix cmd in my C program

Hello experts, How can I retrieve the output from a Unix command and use it as string variable in my C program? For example, when I issue the command 'date' I get: Tue Jun 11 09:54:16 EEST 2009 I do not want to redirect the output of the command to a file and then open the file from... (3 Replies)
Discussion started by: Goseib
3 Replies

8. UNIX for Dummies Questions & Answers

unix cat gives no output

hi, i searched the forum, but found no thread relate to this; so sorry if it's duplicated. I'm using unix cat command but it gives no output. I check permission, owner and group; all of which are OK. I could do less and vi. any suggestions? thanks, (2 Replies)
Discussion started by: notvwatcher
2 Replies

9. Programming

How to use a .exe with a compiled program.

I am confused about how to use a .exe file in unix along with a compiled C++ program. I've been using emacs and I compiled with g++, but I have no idea how that relates to use with a .exe. (1 Reply)
Discussion started by: adamsy
1 Replies

10. Programming

Running a compiled Program

Just getting into the Unix command line programming and am unable to run any program I write. I am using a Makefile and the source is compiling but when I enter the name of the output file I get back: bash: lab01exe.out: command not found I'm sure I am just dooing something simple... (2 Replies)
Discussion started by: Krebsbac
2 Replies
Login or Register to Ask a Question