Подставить строку

Есть ap_scan. Из документацииwpa_supplicant.conf:

# AP scanning/selection
# By default, wpa_supplicant requests driver to perform AP scanning and then
# uses the scan results to select a suitable AP. Another alternative is to
# allow the driver to take care of AP scanning and selection and use
# wpa_supplicant just to process EAPOL frames based on IEEE 802.11 association
# information from the driver.
# 1: wpa_supplicant initiates scanning and AP selection; if no APs matching to
#    the currently enabled networks are found, a new network (IBSS or AP mode
#    operation) may be initialized (if configured) (default)
# 0: driver takes care of scanning, AP selection, and IEEE 802.11 association
#    parameters (e.g., WPA IE generation); this mode can also be used with
#    non-WPA drivers when using IEEE 802.1X mode; do not try to associate with
#    APs (i.e., external program needs to control association). This mode must
#    also be used when using wired Ethernet drivers (including MACsec).
# 2: like 0, but associate with APs using security policy and SSID (but not
#    BSSID); this can be used, e.g., with ndiswrapper and NDIS drivers to
#    enable operation with hidden SSIDs and optimized roaming; in this mode,
#    the network blocks in the configuration file are tried one by one until
#    the driver reports successful association; each network block should have
#    explicit security policy (i.e., only one option in the lists) for
#    key_mgmt, pairwise, group, proto variables
# Note: ap_scan=2 should not be used with the nl80211 driver interface (the
# current Linux interface). ap_scan=1 is optimized work working with nl80211.
# For finding networks using hidden SSID, scan_ssid=1 in the network block can
# be used with nl80211.
# When using IBSS or AP mode, ap_scan=2 mode can force the new network to be
# created immediately regardless of scan results. ap_scan=1 mode will first try
# to scan for existing networks and only if no matches with the enabled
# networks are found, a new IBSS or AP mode network is created.
ap_scan=1

Работает ли это или нет, может зависеть от вашего драйвера беспроводной локальной сети и деталей того, как вы хотите подключиться.

2
09.03.2021, 14:36
2 ответа

Вы можете выполнить ряд операций поиска/замены.

:%s/,/\r/g
:%s/^"
:v/:/s/^/Cisco-AVPair":"
:%s/\v":\[?"/ \= "

что переводится как

  1. заменить каждый ,новой строкой
  2. удалить все ведущие кавычки
  3. заменить начало строк , не содержащих , содержащих :, наCisco-AVPair":"
  4. заменить все ":["на= "
2
18.03.2021, 22:26

Похоже, вы преобразовываете документ JSON (, который вы изменили ради ответа на вопрос, так что он больше не является допустимым документом JSON )в TOML. Показанный вами TOML не является вполне допустимым, так как он содержит повторяющиеся ключи.

Предполагая, что ваш исходный объект JSON

{
  "User-Password": "aaaa",
  "Calling-Station-Id": "bbbb",
  "Eltex-AVPair": "cccc",
  "h323-call-type": "dddd",
  "Framed-IP-Address": "eeee",
  "NAS-IP-Address": "ffff",
  "Cisco-AVPair": [
    "xpgk-request-type=gggg",
    "xpgk-src-number-in=hhhh",
    "xpgk-dst-number-in=iiii",
    "xpgk-src-number-out=jjjj",
    "xpgk-dst-number-out=kkkk",
    "h323-gw-address=llll"
  ],
  "Acct-Session-Id": "mmmm",
  "User-Name": "nnnn",
  "Called-Station-Id": "oooo",
  "h323-gw-id": "pppp",
  "Event-Timestamp": "qqqq",
  "h323-conf-id": "rrrr",
  "h323-call-origin": "ssss",
  "NAS-Port-Type": "tttt",
  "NAS-Port": "uuuu"
}

Вы можете преобразовать его в TOML с помощью различных инструментов, например yqизhttps://kislyuk.github.io/yq/или с помощью yjизhttps://github.com/sclevine/yj.

С yq,

yq -t. file

или с yj,

yj -jt <file

В обоих случаях результирующий документ TOML будет

User-Password = "aaaa"
Calling-Station-Id = "bbbb"
Eltex-AVPair = "cccc"
h323-call-type = "dddd"
Framed-IP-Address = "eeee"
NAS-IP-Address = "ffff"
Cisco-AVPair = [ "xpgk-request-type=gggg", "xpgk-src-number-in=hhhh", "xpgk-dst-number-in=iiii", "xpgk-src-number-out=jjjj", "xpgk-dst-number-out=kkkk", "h323-gw-address=llll",]
Acct-Session-Id = "mmmm"
User-Name = "nnnn"
Called-Station-Id = "oooo"
h323-gw-id = "pppp"
Event-Timestamp = "qqqq"
h323-conf-id = "rrrr"
h323-call-origin = "ssss"
NAS-Port-Type = "tttt"
NAS-Port = "uuuu"
0
15.10.2021, 08:44

Теги

Похожие вопросы