shell 中调用其他的脚本
方法有三种:
1 使用source
2 使用 .
3 使用sh
简单实验:
first.sh
#!/bin/bash
echo 'your are in first file'
second.sh
#!/bin/bash
echo 'your are in second file'
source first.sh // . first.sh // sh first.sh
执行结果:
your are in second file
your are in first file
现在讨论关于参数传递:
first.sh
#!/bin/bash
echo 'your are in first file'
echo "${0} ${1}"
second.sh
#!/bin/bash
echo 'your are in second file'
echo "${0} ${1}"
. first.sh ${2} //source first.sh
执行:./second.sh abc 123
your are in second file
./second.sh abc
your are in first file
./second.sh 123
改变second.sh
second.sh
#!/bin/bash
echo 'your are in second file'
echo "${0} ${1}"
sh first.sh ${2}
执行:
./second.sh abc 123
结果:
your are in second file
./second.sh abc
your are in first file
first.sh 123
所以在调用的那个脚本需要传递参数的时候还是要注意选对方法的
shell 中调用其他的脚本的更多相关文章
- Shell中 调用/引用/包含 另外的脚本文件的两种方法
脚本 first (测试示例1) #!/bin/bash echo 'your are in first file' 问)在当前脚本文件中调用另外一个脚本文件? 方法一: 使用 source 脚本 s ...
- shell中调用R语言并传入参数的两种步骤
shell中调用R语言并传入参数的两种方法 第一种: Rscript myscript.R R脚本的输出 第二种: R CMD BATCH myscript.R # Check the output ...
- shell中调用jenkins API批量运行历史任务
shell中调用jenkins API批量运行jenkins带参数的任务: #!/bin/sh #startdate=20150127 startdate=20150201 while [ " ...
- shell 获得调用的python脚本的print值和错误log
1. shell 获得调用的python脚本的print值 python test.py > out.log 2.shell 获得调用的python脚本的错误log python test.py ...
- Linux/Unix shell 脚本中调用SQL,RMAN脚本
Linux/Unix shell脚本中调用或执行SQL,RMAN 等为自动化作业以及多次反复执行提供了极大的便利,因此通过Linux/Unix shell来完成Oracle的相关工作,也是DBA必不可 ...
- shell脚本中调用另一个脚本的三种不同方法(fork, exec, source)
fork ( /directory/script.sh) fork是最普通的, 就是直接在脚本里面用/directory/script.sh来调用script.sh这个脚本. 运行的时候开一个sub- ...
- 在shell脚本中调用另一个脚本的三种不同方法(fork, exec, source)——转载
原文链接:http://blog.chinaunix.net/uid-22548820-id-3181798.html fork ( /directory/script.sh) :如果shell中包含 ...
- Shell脚本中调用另外一个脚本的方法
(转载): 在Linux平台上开发,经常会在console(控制台)上执行另外一个脚本文件,经常用的方法有:./my.sh 或 source my.sh 或 . my.sh:这三种方法有什么不同呢?我 ...
- Linux脚本中调用SQL,RMAN脚本
Linux/Unix shell脚本中调用或执行SQL,RMAN 等为自动化作业以及多次反复执行提供了极大的便利,因此通过Linux/Unix shell来完成Oracle的相关工作,也是DBA必不可 ...
随机推荐
- codeforces B.Fixed Points
link:http://codeforces.com/contest/347/problem/B 很简单,最多只能交换一次,也就是说,最多会增加两个.可能会增加一个.也可能一个也不增加(此时都是fix ...
- thinkphp + 美图秀秀api 实现图片裁切上传,带数据库
思路: 1.数据库 创建test2 创建表img,字段id,url,addtime 2.前台页: 1>我用的是bootstrap 引入必要的js,css 2>引入美图秀秀的js 3.后台: ...
- CentOS7 搭建python3 Django环境
yum install gcc yum install make yum install openssl-devel -y yum install sqlite-devel -y wget https ...
- 用JQuery动态为选中元素添加/删除类
在做一些tab页功能时,我们经常会见到如下样式: 即当选中一个元素时,在此元素下会添加相应的类,以示区别.今天就研究了一下如何用JQuery实现此效果. 1. HTML代码 <a id=&quo ...
- EL表达式有无双引号的区别
最近做项目时发现原来对EL表达式理解太浅,通过一个springMVC项目,加深了对其的理解,下面总结一下,如发现有不对之处,请批评指正: 1.在单独的js文件中,EL表达式无效,如:var type= ...
- IO:OutPutStream
OutputStream类(java.io.OutputStream) public abstract class OutputStream extends Object implements Clo ...
- Python之路,day7-Python基础
os.system 输出命令结果到屏幕,返回命令执行状态os.popen("dir").read()#会保存命令的执行结果输出py2.7commandscommands.getst ...
- python fork 用法
import os import sys ips = ( "192.168.45.%s" % i for i in range(1,255)) for ip in ips: pid ...
- Linux LVM硬盘管理之二:创建逻辑卷步骤
创建逻辑卷(LV)的顺序:Linux分区---物理卷(PV)---卷组(VG)---逻辑卷(LV)---挂载到文件系统 删除逻辑卷(LV)的顺序:卸载文件系统----逻辑卷(LV)---卷组(VG)- ...
- MySql 打开日志文件
-- 查看系统变量 show variables like '%general%'; set global general_log=on;