Previous: Exec, Up: Subprocess Execution


13.2 Using Exec

Abbreviations:

Examples:

!/bin/sh
exec /bin/sh
exec ... /bin/sh
All of the above are equivalent. Creates another shell in the same window, while the original shell is still running. Output of both shells is displayed and user input is sent to the new /bin/sh.
!!stty 19200
exec!stty 19200
exec !.. stty 19200
All of the above are equivalent. Set the speed of the window's tty. If your stty command operates on stdout, then add another ‘!’. This is a useful command, when a screen window is directly connected to a serial line that needs to be configured.
|less
exec !..| less
Both are equivalent. This adds a pager to the window output. The special character ‘|’ is needed to give the user control over the pager although it gets its input from the window's process. This works, because ‘less’ listens on stderr (a behavior that screen would not expect without the ‘|’) when its stdin is not a tty. Less versions newer than 177 fail miserably here; good old pg still works.
!:sed -n s/.*Error.*/\007/p
Sends window output to both, the user and the sed command. The sed inserts an additional bell character (oct. 007) to the window output seen by screen. This will cause 'Bell in window x' messages, whenever the string ‘Error’ appears in the window.