For Java,python, you can use the import method to make calls between scripts or modules, for example:
>>> Import math>>> math.sqrt (4) 2.0
how to invoke other shell scripts in the shell. Or a variable in another script, what about the function?
method One: . . /subscript.sh
Method Two: Source ./subscript.sh
Attention:
- There are spaces between the two points. Never mind.
- Two scripts are not in the same folder. To use an absolute path
- For simplicity, pass often uses the first method
Like what:
- Main.sh #主脚本
- Subscripts.sh #子脚本, or the script that was tuned
# # #subscripts. sh script contents such as the following: ####!/bin/bashstring= "hello,world! \ n "
# # #main. sh script contents such as the following ####!/bin/bash. ./subscripts.shecho-e ${string}exit 0
Output Result:
# chmod +x./main.sh#./main.shhello,world!#
Note:
- The called script can have no running permissions. Call script must have operational permissions
- chmod +x./main.sh #注意这里要有点, otherwise the bash script may find less than
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Shell learning: Calling between scripts