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

How to use the $PATH environment variable to find executable files

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "how to use the $PATH environment variable to find executable files in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

8 convention

Authors are not forced to follow these management, but following these conventions makes it easier for resource agents to understand and navigate (LeaseSurprise principles)

8.1 easy-to-understand parameter name

Some parameter names are supported by a variety of resource agents. For new resource proxies, it is better to follow these names:

Binary-executable code for managing resources, such as server background processes

Config-the full path to the configuration file

Pid-saves the full path of the pid file

Log-the full path to the log file

Socket-the full path to the unix socket file

Ip-the ip address bound by the backend service process

Port-TCP and UDP ports bound by the server process

8.2 default value of parameter

The default resource agent parameter is usually initialized by a variable suffixed with _ default:

one

two

three

four

# Defaults

OCF_RESKEY_superfrobnicate_default=0

: ${OCF_RESKEY_superfrobnicate=$ {OCF_RESKEY_superfrobnicate_default}}

Note: the resource agent should set the default value in the metadata information that does not indicate that required is a parameter.

8.3 use the $PATH environment variable to find the executable file

When a resource agent is designed to support executable files as parameters (such as daemon, or clients that query status), this parameter should be found in the path defined by the environment variable in $PATH. Do not provide the full path name. Such as the following implementation:

one

two

three

# Good example-do it this way

OCF_RESKEY_frobnicate_default= "frobnicate"

: ${OCF_RESKEY_frobnicate= "${OCF_RESKEY_frobnicate_default}"}

The following implementation is not good:

one

two

three

# Bad example-avoid if you can

OCF_RESKEY_frobnicate_default= "/ usr/local/sbin/frobnicate"

: ${OCF_RESKEY_frobnicate= "${OCF_RESKEY_frobnicate_default}"}

It's the same rule by default.

This is the end of the content of "how to find executable files with the $PATH environment variable in linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report