Linux Shell Scripting Bootcamp by James Kent Lewis
Author:James Kent Lewis
Language: eng
Format: epub, pdf
Publisher: Packt Publishing
In the terminal where script7 was running you will see it has stopped with the word Killed in it.
Note, be sure to kill the right process!
In the example above, PID 29880 is my text editor session where I am writing script7. Killing that would not be a good idea :).
Now for some fun! The next script allows you to draw crude pictures on the screen:
Chapter 5 - Script 8
#!/bin/sh # # 5/16/2017 # echo "script8 - Linux Scripting Book" # Subroutines cls() { tput clear } move() # move cursor to row, col { tput cup $1 $2 } movestr() # move cursor to row, col { tput cup $1 $2 echo -n "$3" # display string } init() # set initial values { minrow=1 # terminal boundaries maxrow=24 mincol=0 maxcol=79 startrow=1 startcol=0 } restart() # clears screen, sets initial cursor position { cls movestr 0 0 "Arrow keys move cursor. 'x' to draw, 'd' to erase, '+' to restart, 'Q' to quit." row=$startrow col=$startcol draw=0 # default is not drawing drawchar="" } checktermsize2() # must be the specified size { rc1=0 # default is no error if [[ $LINES -ne $1 || $COLUMNS -ne $2 ]] ; then rc1=1 # set return code fi return $rc1 } # Code starts here if [ "$1" = "--help" ] ; then echo "Usage: script7 --help" echo " This script shows the basics on how to create a game." echo " Use the arrow keys to move the cursor." echo " Press c to restart and Q to quit." exit 255 fi checktermsize2 25 80 # terminal must be this size rc=$? if [ $rc -ne 0 ] ; then echo "Please size the terminal to 25x80 and try again." exit 1 fi init # initialize values restart # set starting cursor pos and clear screen loop=1 while [ $loop -eq 1 ] do move $row $col # position the cursor here read -n 1 -s ch case "$ch" in A) if [ $row -gt $minrow ] ; then let row-- fi ;; B) if [ $row -lt $maxrow ] ; then let row++ fi ;; C) if [ $col -lt $maxcol ] ; then let col++ fi ;; D) if [ $col -gt $mincol ] ; then let col-- fi ;; d) echo -n "" # delete char ;; x) if [ $col -lt $maxcol ] ; then echo -n "X" # put char let col++ fi ;; +) restart ;; Q) loop=0 ;; esac done movestr 24 0 "Script completed normally." echo "" # carriage return exit 0
Download
Linux Shell Scripting Bootcamp by James Kent Lewis.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7767)
Filmora Efficient Editing by Alexander Zacharias(5796)
The Infinite Retina by Robert Scoble Irena Cronin(5276)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3983)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3935)
Edit Like a Pro with iMovie by Regit(3436)
Linux Administration Best Practices by Scott Alan Miller(2858)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2836)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2522)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2407)
Docker on Windows by Stoneman Elton(2319)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2315)
Creative Projects for Rust Programmers by Carlo Milanesi(2257)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2110)
Hands-On Linux for Architects by Denis Salamanca(2053)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(2005)
Computers For Seniors For Dummies by Nancy C. Muir(2003)
The Old New Thing by Raymond Chen(1941)
Linux Kernel Debugging by Kaiwan N Billimoria(1762)
