Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was trying to use different screen buffer for my script using tput. Below is small script that I am running.

tput smcup
clear
dialog --yesno "Do you want to continue?" 0 0
rc=$?
clear
tput rmcup
if [ "${rc}" == "0" ]; then
  echo Yes
else
  echo No
fi

After the script is finished executing there is a blank part on the screen(as shown below in the image) which is equal to the rows occupied by the prompts before running the script.Ideally tput should have switched to second screen buffer and after executing it should have come back to the first screen buffer. The script switches to the second screen but after coming back it leaves a blank space which shouldn't be there .

enter image description here

share|improve this question
    
please add info like OS, version of dialog, terminal, what command you run with --keep-tite and what happens then... so people don't have to look through all the comments to get the full picture. –  Stéphane Chazelas Mar 14 '13 at 20:31

1 Answer 1

It's an issue with the dialog implementation from http://invisible-island.net/dialog/dialog.html.

On startup, it does a smcup + rmcup by itself, I beleive because ncurses initialisation routine does the smcup and dialog wants to cancel that. So if you do your smcup beforehand, it will have no effect, because the rmcup will cancel it.

A work around is to add the --keep-tite option which tells it not to do that, so dialog will do the smcup on start and rmcup on exit like other ncurses applications if the terminal supports it.

From your comments, you seem to have another problem: you're in a terminal that doesn't support an alternative screen, so whatever you do, you won't be able to use that alternate screen as it doesn't exist.

What you could do though is either use a different terminal that has an alternate screen like putty or the Unix ones from Cygwin on Cygwin's X Server. Or run an X terminal on the remote server to connect to and display on your X Server. Or run a terminal-based terminal emulator inside your terminal that supports an alternate screen like GNU screen.

share|improve this answer
    
output of tput smcup | od -tc is 0000000 033 [ ? 1 0 4 9 h 0000010 and it doesn't switch to alternate screen and value of $TERM is xterm.Sorry I didn't understand about which implementation of dialog and --keep-tite didn't help.I use it like this dialog --keep-tite --yesno "Do you want to continue?" 0 0 –  g4ur4v Mar 14 '13 at 10:33
    
uname -a gives Linux indlin534 2.6.18-238.12.1.el5 #1 SMP Sat May 7 20:18:50 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux and cat /etc/issue gives Red Hat Enterprise Linux Server release 5.6 (Tikanga) –  g4ur4v Mar 14 '13 at 10:39
    
What's the terminal? It doesn't look like an xterm. Does it work in xterm or other terminals? Are you using screen or tmux inside that terminal? –  Stéphane Chazelas Mar 14 '13 at 11:26
    
I am using mobaxterm software to connect to the server (ssh connection). –  g4ur4v Mar 14 '13 at 12:29
    
I have tried putty with no luck.I don't think you are right when you say that the problem is with the terminal.I have tested tput smcup and rmcup without dialog and it works fine,as per my understanding the problem here is with dialog implementation.If my terminal doesn't have an alternate screen,how am I able to use vi and other such commands that require a similar implementation ? –  g4ur4v Mar 14 '13 at 19:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.