Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-01 05:15:10 10月26日 Update

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!

Tags: File parameter resource path agent variable environment process service content background situation convention more server knowledge facet support management utility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft vpn Xiaomi OPPO Reno