无限的.sh文件Python

问题描述 投票:0回答:1

所以我在Ubuntu操作系统上运行一个discord bot,需要做一个无限循环的.sh文件

这是我的Windows .Bat文件。当机器人停机时它会重新启动

:1
py bot.py
goto :1

我在ubuntu .sh文件中试过这个:

#!/bin/bash
while:; do python3 ./Bot.py ;done;

但我得到这个错误:

bash: ./Bot.sh: /bin/ban^M: bad interpreter: No such file or directory

帮助会很棒!

谢谢大家!

ubuntu sh infinite
1个回答
0
投票

在脚本的第一行有一个windows新行(\r\n),因此出错

bash:./ BT.sh:/ bin / ban ^ M:糟糕的翻译

^M表示Windows换行符。尝试使用dos2unix工具将alle行结尾转换为unix换行符\n

© www.soinside.com 2019 - 2024. All rights reserved.