alaister Posted February 21, 2021 Posted February 21, 2021 (edited) This script is copied from this tutorial: https://wiki.helionet.org/tutorials/discord-botMy script: https://alaister.net/cgi-bin/start_bot.py #!/usr/bin/python3.7 print("Content-Type: text/html\n\n") import os, subprocess, signal counter = 0 p = subprocess.Popen(['ps', '-u', 'lj'], stdout=subprocess.PIPE) out, err = p.communicate() for line in out.splitlines(): if 'alaisterbot.py'.encode('utf-8') in line: counter += 1 print("Discord bot is already online!") if counter == 0: subprocess.Popen("/home/lj/alaisterbot.py") print("Starting Discord bot...")When I open the file in the browser, it doesn't even return anything. No errors. Just a blank white page. I expect it shows 'starting discord bot' or 'bot is already online'. The discord bot is also offline after running this. Please help.Server: TommycPanel username: lj Edited February 22, 2021 by alaister
Luigi123 Posted February 21, 2021 Posted February 21, 2021 Did you make sure that you have set up the permissions to 755 for every .py files?
alaister Posted February 22, 2021 Author Posted February 22, 2021 (edited) Yes, I have already set the permissions of start_bot.py, stop_bot.py, and alaisterbot.py to 755. I have also checked that no errors are reported by cPanel. Edit: errors found!My file really exists: https://imgur.com/MVk9YkW[Mon Feb 22 02:22:51.470823 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470442 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470252 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470002 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469874 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469544 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469397 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469079 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093525 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093227 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093049 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092815 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092698 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092451 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092313 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092006 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.489075 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488793 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488651 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488444 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488353 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488183 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488075 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.487820 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470823 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470442 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470252 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.470002 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469874 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469544 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469397 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:51.469079 2021] [cgi:error] [pid 58144] [client 162.158.179.21:29438] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093525 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093227 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.093049 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092815 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092698 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092451 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092313 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 02:22:35.092006 2021] [cgi:error] [pid 60240] [client 162.158.179.21:11462] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.489075 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: FileNotFoundError: [Errno 2] No such file or directory: '/home/lj/alaisterbot.py': '/home/lj/alaisterbot.py': /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488793 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: raise child_exception_type(errno_num, err_msg, err_filename): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488651 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488444 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: restore_signals, start_new_session): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488353 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/usr/local/python3.7/lib/python3.7/subprocess.py", line 775, in __init__: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488183 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: subprocess.Popen("/home/lj/alaisterbot.py"): /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.488075 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: File "/home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py", line 17, in <module>: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py[Mon Feb 22 01:02:11.487820 2021] [cgi:error] [pid 41533] [client 172.68.254.39:15194] AH01215: Traceback (most recent call last):: /home/lj/public_html/domains/alaister.net/cgi-bin/start_bot.py Edited February 22, 2021 by alaister
alaister Posted February 22, 2021 Author Posted February 22, 2021 I solved the problem after reading this old discussion:https://ubuntuforums.org/archive/index.php/t-1751674.html I must change the script from CRLF to LF.
wolstech Posted February 22, 2021 Posted February 22, 2021 Yep, line endings will cause all sorts of weird issues with Python. You need to make sure they're unix style 1
Recommended Posts