Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the script cannot be executed due to a problem with the script format of the Linux operating system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Linux operating system script format problems lead to script can not be executed how to do, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Recently, I have been doing cluster initialization work for a mysql mgr+proxysql. When the proxysql deployment is completed and proxysql is enabled to automatically detect the running status of the mysql cluster, the proxysql backend log reports an error message: the script cannot be executed, and the script file or path does not exist, but it is correct to check the path of the file reported by linux command ls-l, damn it. In desperation, running the script manually also reports that the command or file does not exist:-bash:. / gr_sw_mode_checker.sh: / bin/ bash ^ M: bad interpreter: No such file or directory. However, saw ^ M, too familiar, vi looked at the next file format, unexpectedly is dos format, and then formatted into unix format, proxysql is more important than can call the script, almost burst into tears.

The following is the record of the problem handling process for later reference:

1. When proxysql enables scheduler, the backend log indicates that the call to the script failed.

[root@mmgrpro1 proxysql] # tail-f proxysql.log

2018-08-01 00:17:28 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): No such file or directory

2018-08-01 00:17:31 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): No such file or directory

2018-08-01 00:17:34 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): No such file or directory

2. The linux operating system layer checks whether the path where the script is located exists.

[root@mmgrpro1 proxysql] # ls-l / var/lib/proxysql/gr_sw_mode_checker.sh

-rwxr-xr-x 1 mysql mysql 8292 Jul 31 15:47 / var/lib/proxysql/gr_sw_mode_checker.sh

[root@mmgrpro1 proxysql] #

At this point, things reached an impasse, and the script clearly existed, but proxysql said that the script could not be found. It has happened before, if the script does not have execute permission

Proxysql will report permission denied:

2018-07-31 16:57:39 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): Permission denied

2018-07-31 16:57:44 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): Permission denied

2018-07-31 16:57:48 MySQL_Monitor.cpp:1362:monitor_ping (): [ERROR] Server 192.168.10.131 missed 3306 missed 3 heartbeats, shunning it and killing all the connections

2018-07-31 16:57:49 ProxySQL_Admin.cpp:7947:run_once (): [ERROR] Scheduler: Failed to run / var/lib/proxysql/gr_sw_mode_checker.sh

Execve (): Permission denied

3. Self-reflection, I have seen numerous changes in the implementation plan, and checked it several times against the deployment environment. No abnormality is found. Proxysql means that the script failed to be fetched.

I had no choice but to execute the script by hand, but strangely enough, bash also reported that the file did not exist:

[root@mmgrpro1 proxysql] #. / gr_sw_mode_checker.sh

-bash:. / gr_sw_mode_checker.sh: / bin/ Bash ^ M: bad interpreter: No such file or directory

[root@mmgrpro1 proxysql] # ls-l / var/lib/proxysql/gr_sw_mode_checker.sh

-rwxr-xr-x 1 mysql mysql 8292 Jul 31 15:47 / var/lib/proxysql/gr_sw_mode_checker.sh

[root@mmgrpro1 proxysql] #

However, I saw the familiar face / bin/ bash ^ M and finally found the crux of the problem. The script code I copied from the web page was edited with UE.

The script format is in DOS format and needs to be converted to unix format on unix or linux platforms.

4. Problem handling, using vi editor, formatting script

-- vi script name, enter shift+:, and then enter set ff? Enter to view the script format

-- set ff? Enter and display it in dos format

-- under vi, convert the script from dos to unix, enter set ff=unix, enter enter, and then save and exit by wq

5. After the script is saved, proxysql successfully fetches the script. Although there are some exceptions related to the script, it does not report no such file or directory.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report