
268
|
Appendix: bash Script Samples
echo "${bar1}"
showcmd "${hostname}" "./${f}" "${name}"
fi
echo "${bar1}"
showcmd "${hostname}" "./${f}" "${r}"
fi
echo "${bar1}"
echo "# press ^C here when done"
echo "${bar2}"
#----------------------------------------------------------------
# Start rsync in daemon mode.
#----------------------------------------------------------------
s="DONE"
trap 's="SIGINT ... DONE"' INT
trap 's="SIGTERM ... DONE"' TERM
rsync --daemon --no-detach "--config=${conffile}" "--port=${port}"
rm -f "${conffile}" "${lockfile}"
echo "${s}"
Integrating ssh and screen
You should already be familiar with the ssh command, which connects to another
computer and starts a shell there in a secure manner. The screen command is a use-
ful tool that allows such a shell session to be held in an active state, with its screen
contents intact, when you disconnect from the remote computer. The held shell ses-
sion can then be reconnected later, even from a different computer. It is also possi-
ble to have two or more connections to the same shell session.
The following script makes an ssh connection and starts a named screen session in
one command. The benefit of using this script is quicker connecting and disconnect-
ing when working with multiple servers.
This script is used much like the ssh command. The ssh syntax that specifies the
username and hostname of the remote session is expanded to also include ...