linux脚本expect分区,linux – 从不同位置执行Expect脚本

我试图从两个不同的位置运行我的Expect脚本,它将使用引用的以下Expect可执行文件:

>我的linux主目录(#!/usr/bin/expect)

>另一台服务器上的清晰视图(#!/ clearlib / vobs / otherdir / bin / expect)

问题是我无法在两个地方运行脚本,除非我将Expect可执行文件位置的引用更改为文件的第一行.

如何获取相应目录的Expect可执行文件的正确实例?

解决方法:

如果在两台服务器上正确设置了路径,则可以使用/usr/bin/env:

#!/usr/bin/env expect

这将使用在PATH中找到的expect(在一种情况下为/usr/bin,在另一种情况下为/ clearlib / vobs / otherdir / bin)

By instead using env as in the example, the interpreter is searched for and located at the time the script is run.

This makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches for a match in every directory on the executable search path.

It also suffers from the same problem in that the path to the env binary may also be different on a per-machine basis.

标签:shell,linux,automation,clearcase,expect

来源: https://codeday.me/bug/20190629/1330592.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值