不少Linux用户没有知叙shell不只可以编纂剧本,借能正在剧本上挪用另外一个剧本文件,包孕php文件,这么详细应该若何挪用呢?上面小编便给各人引见高Linux shell挪用另外一个剧本文件的要领,没有会挪用剧本的伴侣能够去教习高。
剧本 first (测试示例1)
代码以下
#!/bin/bash
echo ‘your are in first file’
答)正在以后剧本文件外挪用别的一个剧本文件?
要领一: 运用 source
剧本 second (测试示例2)
#!/bin/bash
echo ‘your are in second file’
source first
要领两: 运用 。
剧本 second (测试示例3)
#!/bin/bash
echo ‘your are in second file’
。 first
source filename战 。 filename 应该是异一回事,皆是正在*以后*Shell环境外执止剧本。也能够运用sh filename,这是正在以后Shell的子Shell外执止剧本。
能够经由过程上面那二个剧本去领会三种挪用体式格局的差别:
1.sh
#!/bin/bash
A=B
echo “PID for 1.sh before exec/source/fork:$$”
export A
echo “1.sh: $A is $A”
case $1 in
exec)
echo “using exec…”
exec 。/2.sh ;;
source)
echo “using source…”
。 。/2.sh ;;
*)
echo “using fork by default…”
。/2.sh ;;
esac
echo “PID for 1.sh after exec/source/fork:$$”
echo “1.sh: $A is $A”
2.sh
#!/bin/bash
echo “PID for 2.sh: $$”
echo “2.sh get $A=$A from 1.sh”
A=C
export A
echo “2.sh: $A is $A”
执止状况:
$ 。/1.sh
PID for 1.sh before exec/source/fork:5845364
1.sh: $A is B
using fork by default…
PID for 2.sh: 5242940
2.sh get $A=B from 1.sh
2.sh: $A is C
PID for 1.sh after exec/source/fork:5845364
1.sh: $A is B
$ 。/1.sh exec
PID for 1.sh before exec/source/fork:5562668
1.sh: $A is B
using exec…
PID for 2.sh: 5562668
2.sh get $A=B from 1.sh
2.sh: $A is C
$ 。/1.sh source
PID for 1.sh before exec/source/fork:5156894
1.sh: $A is B
using source…
PID for 2.sh: 5156894
2.sh get $A=B from 1.sh
2.sh: $A is C
PID for 1.sh after exec/source/fork:5156894
1.sh: $A is C
$
下面便是Linux shell挪用剧本文件的要领引见了,当您正在挪用php文件时,纷歧定运用php,也否运用shell号令真现。
相关文章