Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-17-2007, 02:50 PM
|
#1
|
|
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,167
|
cat on binary: garbles stdout chars, wastes terminal
This is more of an "I'm curious why" question... in regards to a command like this:
Strange things happen. The console prompt becomes garbled nonsense. This phenomenon is not unique to vi, either; many binaries have this effect on standard out when cat'ed.
Why does this happen - are bits of the binary being executed? But if this is so, why is the file not executed properly? Lastly, is there anyway to safeguard the cat command from this sort of thing?
Last edited by jhwilliams; 07-17-2007 at 02:51 PM.
|
|
|
|
07-17-2007, 02:57 PM
|
#2
|
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,591
|
Terminal programs emulate real hardware, like vt100 (which was an actual device) and xterms. These devices respond to control characters - binary values that do not represent alphanumeric characters - by performing special functions. This is what causes the result you see.
You can usually correct the problem by running the command 'reset' (even if you can't see what you are typing, just type it and hit enter).
There is no need to 'safeguard' the cat command, as no damage is done. Rather than directly using cat on binaries, you probably want to use strings to extract human readable information:
cat /bin/vi | strings | less
You can determine the type of file by using the file command:
file /bin/vi
|
|
|
|
07-17-2007, 03:10 PM
|
#3
|
|
Member
Registered: Feb 2004
Location: Waimanalo, HI
Distribution: Slackware 10, Fedora 6
Posts: 308
Rep:
|
Also, you can "vi /bin/vi" to look inside (if "vi" is vim, anyway).
|
|
|
|
07-17-2007, 03:55 PM
|
#4
|
|
Senior Member
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,392
Rep:
|
you can filter out binary values without a character representation and display only the strings.
This is nice to find hidden strings in the binary program
Code:
cat /bin/vi | strings
or more directly,
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:00 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|