UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old April 22nd, 2004, 12:40 PM
Casticus Casticus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 Casticus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
clear screen escape sequence, used for unix written in c

We have a big class project making our own shell for unix, of course it is very simple shell with like 10 commands. Right now I am doing the clear screen command. I know that to do it I have to do an escape sequence. That is esc[2j. Here is the question, do I have to use the ascii character for this doing \033[2j or can I just leave it as esc[2j.

Also, we are using bison and flex to do this, under clear screen, would the code just be like print \0333[2j to clear the screen, and then some more code to bring up the prompt after?

Reply With Quote
  #2  
Old April 25th, 2004, 02:19 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
I think you should do your own schoolwork, but I will give you a few hints. You do not want to build in escape sequences into your code. One day I might use your program from an HP terminal, the next from a Wyse 50 terminal, and the following day from a xterm window. A different escape sequence is needed in each case. The way unix handles this is with the TERM environment variable. (Try "echo $TERM".).

In a c program, you use the curses package. There is a man page on curses and there are web pages and books on curses. Curses acceses the terminfo database and there is "man terminfo". Each terminal type (i. e., each value of TERM) has a terminfo file with all of the escape sequences in it.

And you can use these escape sequence in shell scripts too, via the tput command.

You really should use curses directly. But there is a program called "clear" which will clear your screen. It uses the terminfo database. So you could take a shortcut by invoking it from your c program via system(). This is, however, quite ugly and will not impress your instructor. Good luck with your project.

Reply With Quote
  #3  
Old April 27th, 2004, 07:33 AM
Casticus Casticus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 Casticus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The instructor told us to use an escape sequence for this command... He told us that most terminals know the esc[2j for clear screen so we can just use that. And I am new to programming this type of things, but I would have imagined that when people are doing projects like these, they seek help on the forums? If not, do you suggest I buy expensive books for the last 2 weeks of college?

Reply With Quote
  #4  
Old April 27th, 2004, 06:39 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
No need to imagine. Browse the forum and see for yourself. And I would suggest that you buy the book for two weeks of college and several decades of life after college. Or go to the library and check it out. But I'm not going to type in 100's of pages of info.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > clear screen escape sequence, used for unix written in c


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway