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 ...
- Linux下压缩mp3文件
apt-get install lame lame -b 64 a.mp3 b.mp3 lame是压缩mp3的一个小工具 参数 -b 64 是输出文件的采样率64 a.mp3 是源文件 b.mp3 是 ...
- coderforces #384 D Chloe and pleasant prizes(DP)
Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- float和double精度问题
System.out.println(new BigDecimal(253.90).doubleValue() * 100);25390.0精度正确 System.out.println(new Bi ...
- Zookeeper 的学习与运用
引子 云计算越来越流行的今天,单一机器处理能力已经不能满足我们的需求,不得不采用大量的服务集群.服务集群对外提供服务的过程中,有很多的配置需要随时更新,服务间需要协调工作,这些信息如何推送到各个节点? ...
- js数组键入值push和 arr[]i]区别
push 和 arr[i] 遍历 var arr = new Array(); $(":check").each(function(i){if(this.checked==true ...
- statsd+graphite
一些观点: Statsd:一个nodejs的客户端,用于向graphite的收集器发送数据,使用各类编程语言的客户端响起发送timer,counter等统计数据后,其通过udp定时向graphite发 ...
- unity, 按类型查找文件
- windows下使用ffmpeg进行视频转换和截图。
author:fanfq(xiaoban) Email:fangqing.fan#gmail.comlink:http://fanfq.iteye.com/admin/blogs/655569chan ...
- python之正则表达式
1) 用管道符号(|)匹配多个正则表达式 举例 at | home 匹配 at, home 2) 匹配任意一个单个的字符(.) 举例 f.o 匹配在"f"和"o ...