The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Dec 2008
Posts: 56
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 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Feb 2006
Location: Southern England
Posts: 116
team members?

are you people geting paid?
  #3 (permalink)  
Old 11-26-2009
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,006
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 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Dec 2008
Posts: 56
Quote:
Originally Posted by jim mcnamara View Post
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 (permalink)  
Old 11-26-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
 

Join Date: Dec 2008
Location: .at
Posts: 2,593
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 (permalink)  
Old 11-26-2009
Registered User
 

Join Date: Mar 2008
Posts: 1,342
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 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2009
Posts: 39
Quote:
Originally Posted by bigearsbilly View Post
team members?

are you people geting paid?

I lol'd hard at this ^_^
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Connection problem with gui java program to postgreaql database using unix uci UNIX for Dummies Questions & Answers 2 12-15-2007 09:16 AM
C program Output arunviswanath High Level Programming 3 07-05-2007 02:16 AM
How to use a .exe with a compiled program. adamsy High Level Programming 1 10-04-2005 01:03 AM
Capturing output from C++ program GMMike UNIX for Dummies Questions & Answers 3 03-08-2005 09:04 AM
Running a compiled Program Krebsbac High Level Programming 2 09-07-2001 05:39 PM



All times are GMT -4. The time now is 09:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0