Using tushell programming to call functions or variables defined by other files #! /Bin/shif [-rbackfunc]; then./home/fef/shell/backfunc # "." There is an empty backend.
Methods for calling functions or variables defined by other files in Ubuntu Shell programming
- #! /Bin/sh
- If [-r backfunc]; then
- ./Home/fef/shell/backfunc # "." There is a space behind it, and backfunc must use an absolute path !!
- Else
- Echo "'basename $ 0' cannot locate backfunc file"
- Fi
- Echo-n "Enter the code name :"
- If ["$ CODE "! = "$ _ CODE"]; then
- Echo "Wrong code... exiting... will use default"
- Exit 1
- Fi
- Echo "The environment config file reports"
- Echo "FULL backup Required: $ _ FULLBACKUP"
- Echo "$ LOGFILE"
The content of the backfunc file is as follows:
- #! /Bin/sh
- # Name: backfunc
- # Config file that holds the defaults for the archive systems
- _ CODE="Comet"
- _ FULLBACKUP="Yes"
- _ LOGFILE="/Logs/backup"
- _ DEVICE="/Dev/rmt/On"
- _ INFORM="Yes"
- _ PRINT_STATS="Yes"
Run the above script $: sh readfunc comet.
Result:
The environment config file reports
FULL backup Required : Yes
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2