[Linux][ubuntu][Perl]bad interpreter: No such file or directory

本文介绍了一个Perl脚本从Windows移植到Ubuntu Linux过程中遇到的问题及解决方法。主要讨论了因换行符不同导致的解释器错误,并演示了如何使用dos2unix工具将脚本转换为Linux格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在windows 系统上 写了个perl脚本来给 android 手机做压力测试。但是放到linux 系统上work 起来不是很友好。


该脚本放到 ubuntu 1204 64bit 系统上执行时会报如下错误:


$ ./adb_script.pl

bash: ./adb_script.pl: /usr/bin/perl^M: bad interpreter: No such file or directory

然后对该脚本用 dos2unix 进行格式转化,


$ dos2unix ./adb_script.pl

The program 'dos2unix' is currently not installed.  To run 'dos2unix' please ask your administrator to install the package 'dos2unix'

发现 ubuntu 默认未安装 dos2unix


$ sudo apt-get install dos2unix
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dos2unix
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 60.1 kB of archives.
After this operation, 246 kB of additional disk space will be used.
Get:1 http://mirrors.163.com/ubuntu/ precise/universe dos2unix amd64 5.3.1-1 [60.1 kB]
Fetched 60.1 kB in 0s (2,893 kB/s)
Selecting previously unselected package dos2unix.
(Reading database ... 207091 files and directories currently installed.)
Unpacking dos2unix (from .../dos2unix_5.3.1-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up dos2unix (5.3.1-1) ...


安装完 dos2unix 后,重新执行

$ dos2unix ./adb_script.pl
dos2unix: converting file ./adb_script.pl to Unix format ...

然后再执行脚本文件,脚本完美的在ubuntu上执行。

$ ./adb_script.pl
adb_device_check start...


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值