Ubuntu 无限.sh文件

Ubuntu 无限.sh文件,ubuntu,sh,infinite,Ubuntu,Sh,Infinite,所以我在Ubuntu操作系统上运行一个discord机器人,需要一个无限循环.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操作系统上运行一个discord机器人,需要一个无限循环.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
帮帮忙太好了


谢谢大家

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

bash:./Bot.sh:/bin/ban^M:解释器错误

^M
表示windows换行符。
尝试使用工具
dos2unix
将所有行尾转换为unix新行
\n

while和之间需要有一个空格:(尽管特定错误与hellow所说的有关)