Linux&&shell&&/usr/bin/expect: bad interpreter: No such file or directory

Linux&&shell&&/usr/bin/expect: bad interpreter: No such file or directory


问题现象:

root@dfq:/home# nohup ./scp.sh &
[1] 1787
root@dfq:/home# nohup: ignoring input and appending output to ‘nohup.out’
nohup: failed to run command ‘./scp.sh’: No such file or directory
^C
[1]+  Exit 127                nohup ./scp.sh
root@dfq:/home# ./scp.sh 
-bash: ./scp.sh: /usr/bin/expect: bad interpreter: No such file or directory

问题分析:
先贴个脚本

#!/usr/bin/expect -f
#定义密码
set password qwe123

#download
spawn scp -r  -P 27 root@192.168.1.11:/mnt/backup/192.168.1.11.tar.gz /home/
set timeout 300 

expect "root@192.168.1.11's password:"
set timeout 300 

send "$password\r"
set timeout 300 

send "exit\r"
expect eof 

脚本中第一行调用了"#!/usr/bin/expect -f",该服务不存在,所以提示文件不存在错误。
解决方法:

root@dfq:/home# apt-get install expect
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libtcl8.6
Suggested packages:
  tcl8.6
The following NEW packages will be installed:
  expect libtcl8.6
0 upgraded, 2 newly installed, 0 to remove and 60 not upgraded.
Need to get 992 kB of archives.
After this operation, 4,115 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libtcl8.6 amd64 8.6.1-4ubuntu1 [841 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main expect amd64 5.45-5ubuntu1 [152 kB]
Fetched 992 kB in 2s (441 kB/s) 
Selecting previously unselected package libtcl8.6:amd64.
(Reading database ... 85279 files and directories currently installed.)
Preparing to unpack .../libtcl8.6_8.6.1-4ubuntu1_amd64.deb ...
Unpacking libtcl8.6:amd64 (8.6.1-4ubuntu1) ...
Selecting previously unselected package expect.
Preparing to unpack .../expect_5.45-5ubuntu1_amd64.deb ...
Unpacking expect (5.45-5ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libtcl8.6:amd64 (8.6.1-4ubuntu1) ...
Setting up expect (5.45-5ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.14) ...
root@dfq:/home# nohup ./scp.sh &
[1] 2137
root@dfq:/home# nohup: ignoring input and appending output to ‘nohup.out’
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值