Many Linux users don't know that the shell can not only edit the script, but also call another script file on the script, including the php file. How should it be called? The following small series will introduce you to the Linux shell to call another script file, friends who do not call the script can learn.
script first (Test Example 1)
code below
#! /bin/bash
echo ‘your are in first file’
Q) Calling another script file in the current script file?
Method one: Use source
script second (test example 2)
#! /bin/bash
echo ‘your are in second file’
source first
Method 2: Use .
Script second (test example 3)
#! /bin/bash
echo ‘your are in second file’
. First
source filename and . Filename should be the same thing, both in the *current *Shell environment to execute the script. You can also use sh filename, which is to execute the script in the subshell of the current shell.
You can use the following two scripts to understand the difference between the three calling methods:
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”
Implementation:
$ . /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
$
The above is the introduction of the Linux shell call script file. When you are calling a php file, you don't have to use php, you can also use shell commands.
FreeBSD is a UNIX-like operating system, and there is a certain difference between UNIX and UNIX sys
GCC is a GNU compiler suite, need to be installed in the network, its installation is simple, but ca
RHCS is a cluster in Red Hat system, which integrates many useful tools in RHCS. These tools of Red
In the Ubuntu system operation, each time you shut down, there is a certain amount to indicate wheth
How to modify the time zone of CentOS6 system?
The basic process of setting serial port properties in Linux system
How to implement multi-window operation on Linux on Linux
How to modify the color of the Linux system shell script output text
Repairing database skills after Linux system crashes
Ubuntu system installation FFmpeg step
What should I do if hacmp fails to start after AIX is powered off?
How to solve the shell script stop execution when the Linux system is scheduled?
Linux system smbclient command usage
Two methods of Deepin system update
How does the Linux system simulate the get or post request of Http?
Modify XP settings skill set desktop adjustment
How to solve the problem of Win7 listening to the song suddenly bursting
Graphical steps for fast-pressing tray mounting
How to change the default storage location of SkyDrive
10 questions that must be solved for Windows 7 to succeed
How to control computer through Bluetooth mobile phone under Vista
Windows7 system management wireless network graphic tutorial
Microsoft creates a unified store for Win10, or will compete with the iTunes store