In Java,python, you can use the import method to make calls between scripts or modules, for example:
Copy Code code as follows:
>>> Import Math
>>> Math.sqrt (4)
2.0
How do you invoke other shell scripts in the shell, or variables in other scripts, functions?
Method one:. ./subscript.sh
Method Two: source./subscript.sh
Attention:
1. Between two points, there are spaces, you must pay attention to.
2. Two scripts are not in the same directory, use absolute path
3. For the sake of simplicity, the first method is usually used
For example:
Copy Code code as follows:
Main.sh #主脚本
Subscripts.sh #子脚本, or the script that was tuned
[Code]
[Code]
# # #subscripts. sh script contents are as follows: ###
#!/bin/bash
String= "hello,world! \ n "
Copy Code code as follows:
# # #main. sh script content as follows ###
#!/bin/bash
. ./subscripts.sh
Echo-e ${string}
Exit 0
Output results:
Copy Code code as follows:
# chmod +x./main.sh
#./main.sh
hello,world!
#
Attention:
1. The scripted script can not execute permissions, the calling script must have executable permissions
2.chmod +x./main.sh #注意这里要有点, or bash scripts may not be found