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

When Linux executes the .sh file, it prompts No such file or directory how to solve it.

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "Linux executes .sh file prompts No such file or directory how to solve", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to solve the problem when Linux executes .sh files to prompt No such file or directory.

Problem description

Solution method

Analyze the reason, maybe because of the permission problem encountered in the migration of our platform, we will carry out the permission conversion.

1) convert under Windows:

Use some tools such as editors such as UltraEdit or EditPlus to transcode the script before it is executed in Linux. The conversion method is as follows (UltraEdit): File-- > Conversions-- > DOS- > UNIX.

2) method

Open the sh file with vim and enter:

[plain]

: set ff

Enter, display fileformat=dos, and reformat (www.111cn.net) the file:

[plain]

: set ff=unix

Save exit:

[plain]

: wq

If you execute it again, it will be all right.

3) privilege conversion in linux

You can also convert in Linux:

First of all, make sure the file has executable permissions.

# chmod uplix filename

Then modify the file format

# vi filename

All three methods can easily and quickly solve the problem of executing .sh files and prompting No such file or directory about Linux.

Under the window platform, write the shell script file, migrate to the linux platform, assign executable permissions, and execute the sh file.

Only to remind No such file or directory. Ls, there is indeed the file, how could it happen?

Is it a file format compatibility problem? Open the sh file with vim and enter:

[plain]

: set ff

Enter, display fileformat=dos, and reformat the file:

[plain]

: set ff=unix

Save exit:

[plain]

: wq

If you execute it again, it will be all right. This matter gives me another reminder that the program is written under linux as far as possible, and there may be fewer problems when migrating.

At this point, I believe you have a deeper understanding of "Linux prompts No such file or directory how to solve the .sh file". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Servers

Wechat

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

12
Report