How to emulate ^S/^Q from a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to emulate ^S/^Q from a script
# 1  
Old 02-09-2010
How to emulate ^S/^Q from a script

Hi,

I wrote a little menu script that searches through another script you specify and displays step-names and next to it the text of the step. The scripts are converted JCL from mainframe. It alows you to select steps you want and will then create a new script which includes only the steps you selected. It looks something like
Code:
Step        Selected     Text
S0010       [ ]             S0030 #Here we do some stuff
S0020       [ ]             cp file to otherfile
S0030       [x]             some more commands.....
S0040       [ ]              .
S0050       [ ]              .
                                 .
                                ## End of step 0030

I am using tput to position the cursor for each of the text lines and clear the lines one at a time. You can however notice the clearing/drawing, its a bit slow. I have loaded it into a table so no disk reading involved. When I display the text below the steps it is super fast, no visible delay, but then I dont have to position the cursor, just delete till end of terminal and echo the text.

Because of space, some scripts have a lot of steps plus it looks more impressive, I want to keep the layout as above.

I have been playing with flow control from the command line. i.e. If you type ^S, then type some commands nothing is echoed, then type ^Q it will echo everyting you typed etc.

I want to do the same from the script, I think I am just being thick cannot figure out how. How do I in the script emulate ^S and ^Q. I have been searching all day but most articles are about enabling/disabling flow control via IXON, not what I want.

I want to stop scrolling, do my erase of old lines and echo of new lines, then send to the screen by enabling scrolling again in the script.

Thanks!

---------- Post updated at 04:13 PM ---------- Previous update was at 04:10 PM ----------

My spaces have dissapeared, looks like below, underscore=space

Step_Selected_Text
S0010_[ ]_____S0030 #Here we do some stuff
S0020_[ ]_____cp file to otherfile
S0030_[x]_____some more commands.....
S0040_[ ]_____.
S0050_[ ]_____.
______________.
______________even more commands
______________## End of step 0030

Last edited by vbe; 02-09-2010 at 12:46 PM.. Reason: added code tags
# 2  
Old 02-09-2010
Quote:
My spaces have dissapeared, looks like below, underscore=space
If you used code tags, your formatting would have appeared...
# 3  
Old 02-09-2010
Quote:
Ok thanks, will do this in future
# 4  
Old 02-09-2010
You welcome...

---------- Post updated at 18:02 ---------- Previous update was at 17:58 ----------

To help you, I suppose we would need to see a bit of your script in order to understand some of the logic and figure out what could be possible solutions...
# 5  
Old 02-09-2010
The value of $TERM and a description of the physical terminal (or terminal emulator)?

^S and ^Q are xon and xoff respectively in old serial comms.

Reading between the lines this might be a DEC VTnn terminal emulator in which case ^O should toggle output to the screen.
# 6  
Old 02-10-2010
Some more info

I guess what I want is to create some sort of screen buffer. Not sure if it can be achieved with flow control. I want to stop sending chars to the screen, draw the screen, then send all of the chars at once, instead of one line at a time.

Anyway here is a "Screenshot" of the script running
Code:
Doing p1lld5p1.ksh creating p1lld5p1.ksh.LV21057
Step Selected   Step Text
S0020=A [ ] [ ] S0070=A
S0030=A [ ] [ ] JSTEP=S0070; ((XSTEP+=1)); SCC=0; LCC=0; alias goto="";
S0040=A [ ] [ ] stepctl51
S0050=A [ ] [ ] exportfile IN01 pisop/sysin/p1llbtch
S0060=A [ ] [ ] exportfile IN02 pisop/sysin/p1ld5p1a
S0070=A [X] [ ] cat $IN01 > $SYOT/${JSTEP}_p1ld5p1a
S0080=A [ ] [ ] awk 'print $0"' $IN02 >> $SYOT/${JSTEP}_p1ld5p1a
S0090=A [ ] [ ] awk '2"' $IN02 >> $SYOT/${JSTEP}_p1ld5p1a
S0100=A [ ] [ ] exportfile IN $SYOT/${JSTEP}_p1ld5p1a
S9000=A [ ] [ ] exportfile OUT $SYOT/${JSTEP}_Q3086_MOR_out
S9900=A [ ] [ ] exportfile TRAN psall/p1.xl.periodiccharges2.t3097out
               ### **** comment ***
               exportfile SYSOUT $SYOT/${JSTEP}_SYSOUT
               dbblp -u DFE -d $SAPDBID -BT -i $IN -o $OUT -dt $INPUTDATE -tr $TRAN,a
               #4----------------------------------------------------------------------
               LCC=$?; S0070C=$LCC; ((SCC+=LCC)); ((JCC+=LCC)); S0070R=1; alias goto="";
               if ((S0070C > 8))
               then logmsg1 "step#$JSTEP abterm $SCC"
               alias goto="<<S9900=A"; fi
               goto

And here is the function that displays the step text.
Code:
function DisplayStep
{
stty -echo -raw                                       # Stop keyboard input
##Clear the previous one first
DISPLINE=2                                            # Init var, want to start on line 2
while [ DISPLINE -lt $SCREENLINES ]                   # Clear out the currently displayed text
do
tput cup $DISPLINE 30                               # Position the cursor
## The echo of all the spaces seem to be a lot faster than the tput el to erase a line
##  tput el
echo '                                                                                                                               '
(( DISPLINE++ ))                                    # Add one to var
done
SCREENLINES=2                                         # Init var, want to start on line 2
DISPLINE=2                                            # Init var, want to start on line 2
## Set the field seperator to enter
IFS='
'
for ONELINE in `echo "${STEPDETAIL[$ELEMENT]}"`       # Loop through the text delimited by enter.
do
tput cup $DISPLINE 30                              # Position the cursor
echo "${ONELINE}"                                  # Display the text
(( DISPLINE++ ))                                   # Increase the row to display the next line on
(( SCREENLINES++ ))                                # Count of lines to clear next time the function is called
if [ $DISPLINE == $MAXLINES ]                      # Stop the script from scrolling off the bottom of the screen. Just display as much as it can.
then
   break
fi
done
unset IFS                                             # Reset the IFS
stty -echo raw                                        # Accept keyboard input again
tput cup $CPOSY $CPOSX                                # Put the cursor where it was
}

At the top of the function I would like to stop display to the screen and then at the end enable it again and send all the echoe's at once.

It is probably not possible in a script. This is a Korn shell script.

STTY and Linux info
Code:
speed 38400 baud; rows 62; columns 157; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
 
Linux 2.6.9-89.0.16.ELsmp
i386

Any help with getting the display faster would be appreciated.

It is workable at the moment, but it bugs me. I know using emacs and some sort of C program would be the best, but we don't have C at our site.

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Emulate group-by in shell script

Hello All, I saw this problem on one of the forum and solved it using group-by in oracle sql, though I am a bit curious to implement it using shell script : There is a file having number of operations : Opeation,Time-Taken operation1,83621 operation2,72321 operation3,13288... (11 Replies)
Discussion started by: mukulverma2408
11 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

Emulate fgrep -f in perl

Is there any equivalent of the below requirement in perl fgrep -f file1 file2 > file3 (2 Replies)
Discussion started by: aravindj80
2 Replies

4. UNIX for Dummies Questions & Answers

emulate aix 5.3 , how ....? pearpc didn't work

how to emulate aix 5.3 i had try pearpc , but it didn't work ... someone have some solution? thanks (1 Reply)
Discussion started by: prpkrk
1 Replies

5. UNIX for Dummies Questions & Answers

can I emulate solaris/sparc on virtualbox? Or other emulator to run solaris for sparc in my win7 PC?

Hi Gurus can I emulate solaris/sparc on virtualbox? Or other emulator to run solaris for sparc in my win7 PC? regards, Israel. (9 Replies)
Discussion started by: iga3725
9 Replies

6. Shell Programming and Scripting

Emulate ksh's FPATH variable in bash

Over time i have developed a library of useful (ksh) functions which i use in most of my scripts. I use the ksh's FPATH variable to locate all these functions and use a standard environment-setting-function to always have the same environment in all my scripts. Here is how i begin scripts: ... (3 Replies)
Discussion started by: bakunin
3 Replies

7. Shell Programming and Scripting

Shell quiz: emulate an associative array

Most shells flavors do not have associative arrays a.k.a. maps. How would you emulate an associative array? I had this problem once and found a working solution, but I don't want to spoil the game hence I wont tell it. Wonder if anyone comes up with something better. (5 Replies)
Discussion started by: colemar
5 Replies

8. Shell Programming and Scripting

Script to emulate ls -lh?

Does anyone have a script they would like to share that emulates "ls -lh" in ksh on Solaris 8? Yeah, I know. Real men don't need that wimpy "h." Well, I'm a wimp. ;) (0 Replies)
Discussion started by: shew01
0 Replies

9. UNIX for Dummies Questions & Answers

How can emulate unix on my PocketPC?

I just want to learn more not just reading but also practicing at the same time :) (0 Replies)
Discussion started by: MFT39
0 Replies

10. Shell Programming and Scripting

tool to emulate keystrokes out to a ps/2 device?

hey all, i am trying to connect my mac to my sony DVD changer so that i can control one aspect of it with any kind of shell script or program. the DVD player allows you to plug in a PS/2 keyboard to navigate it's on screen menu. what i want to do is use my mac to navigate my own menus, then... (0 Replies)
Discussion started by: drzoomn
0 Replies
Login or Register to Ask a Question