how to extract only the enabled repository from a repo file? - awk

Im trying to extract only the enabled repos from the file below using awk or grep.
i know there are the native tool for this such as "yum repolist enabled" but i still want to do this using grep awk or even sed.
the output should result with the string inside the [].
for example: "red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-rpms" which is the only enabled repo in this file.
# cat /etc/yum.repos.d/redhat.repo
[red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-rpms]
name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (RPMs)
baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/os
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslcacert = /etc/rhsm/ca/redhat-uep.pem
sslclientkey = /etc/pki/entitlement/key.pem
sslclientcert = /etc/pki/entitlement/11300387955690106.pem
[red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-source-rpms]
name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (Source RPMs)
baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/source/SRPMS
enabled = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslcacert = /etc/rhsm/ca/redhat-uep.pem
sslclientkey = /etc/pki/entitlement/key.pem
sslclientcert = /etc/pki/entitlement/11300387955690106.pem
[red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-debug-rpms]
name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (Debug RPMs)
baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/debug
enabled = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslcacert = /etc/rhsm/ca/redhat-uep.pem
sslclientkey = /etc/pki/entitlement/key.pem
sslclientcert = /etc/pki/entitlement/11300387955690106.pem

awk -v RS= -F '[][]' '/enabled = 1/{print $2}' file

Try
awk '/\[/' infile | sed 's/[][]//g'
I found the square brackets part tricky, here is where I got it from.

Related

Spacevim: neosnippet <Plug> mappings dont work

Problem
I set up my spacevim with builtin autocompletion which provides neosnippet in-box, but when I use my Enter button to perform expansion of a snippet I get just raw output of <Plug>(neosnippet_expand). Also, I've tried to use deoppet snippets, but faced with the same problem. Besides, i tried to remap my how in this post How to autoexpand neosnippet with deoplete dropdown menu? but when I try to expand main I got main<Plug>(neosnippet_expand_or_jump) Here are my configs:
Init.toml:
[options]
# set spacevim theme. by default colorscheme layer is not loaded,
# if you want to use more colorscheme, please load the colorscheme
# layer
colorscheme = "nord"
colorscheme_bg = "dark"
default_indent = 4
expand_tab = false
# snippet_engine = "neosnippet"
# Disable guicolors in basic mode, many terminal do not support 24bit
# true colors
enable_guicolors = true
# Disable statusline separator, if you want to use other value, please
# install nerd fonts
statusline_separator = "arrow"
statusline_iseparator = "arrow"
buffer_index_type = 4
enable_tabline_filetype_icon = true
enable_statusline_mode = false
autocomplete_parens = false
automatic_update = true
# Enable autocomplete layer
[[layers]]
name = 'autocomplete'
# autocomplete_method = 'coc'
auto_completion_tab_key_behavior = "smart"
auto_completion_return_key_behavior = "smart"
Init.vim:
map <F5> :ImportName<CR>
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/main.vim'
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option("num_processes", 4)
let g:spacevim_enable_ycm = 1
let g:ansible_extra_keywords_highlight = 1
let g:coc_filetype_map = {
\ 'yaml.ansibe': 'ansible',
\ }
let g:jedi#completions_enabled = 0
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible
autocmd FileType yaml\|yaml.ansible setlocal ts=2 sts=2 sw=2 expandtab
inoremap <silent><expr><CR> pumvisible() ? deoplete#close_popup()."\<Plug>(neosnippet_expand_or_jump)" : "\<CR>"
Snippets dir list:
╰─$ ls ~/.SpaceVim.d/snippets/
actionscript.snip blade.snip d.snip go.snip liquid.snip objc.snip rust.snip systemverilog.snip vim.snip
ada.snip clojure.snip elixir.snip go.vim lua.snip ocaml.snip scala.snip tex.snip vimspec.snip
apache.snip cmake.snip elm.snip groovy.snip make.snip perl.snip scheme.snip toml.snip vimwiki.snip
applescript.snip coffee.snip erlang.snip haskell.snip markdown.snip php.snip scss.snip twig.snip vue.snip
asciidoc.snip cpp.snip eruby.snip html.snip mediawiki.snip prolog.snip sh.snip typescriptreact.snip xhtml.snip
asciidoctor.snip c.snip fortran.snip javascript.snip mkd.snip python.snip _.snip typescript.snip zsh.snip
asm.snip cs.snip fsharp.snip java.snip moon.snip rails.snip sql.snip verilog.snip
beancount.snip css.snip Gemfile.snip julia.snip neosnippet.snip rst.snip sshconfig.snip vim
bib.snip cuda.snip gnuplot.snip kp19pp.snip nim.snip ruby.snip swift.snip vimshell.snip
Completion sight (if needed):
I want to expand neosnippet snippets, but fail

Error on WPN-XM php7

the systm version is WPNXM-0.8.6-Standard-Setup-php56-w64 . After I intalling php7.0.10_nts and when I change php version appear an error
problem with php7.0.10
Where is a problem ???
If you go to your php 7 folder (C:\server\bin\php) you will find that there are 2 php.ini files:
php.ini-development
php.ini-production
If you copy one of them with the name php.ini. this should fix it.
Edited:
You may need to change paths too like:
extension_dir = "ext"y
error_log = C:\server\logs\php_error.log
include_path = ".;C:\server\bin\php\pear"
upload_tmp_dir = C:\server\temp
;sendmail_path = "C:\server\bin\sendmail\sendmail.exe -t -i"
session.save_path = C:\server\temp
curl.cainfo =C:\server\bin\openssl\ca-bundle.crt
[Xdebug]
; activate remote debugging
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
; profiler
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\server\logs"
xdebug.profiler_output_name = cachegrind.out.%t.%p
[Zend]
zend_extension=C:\server\bin\php\ext\php_opcache.dll
zend_extension=C:\server\bin\php\ext\php_xdebug.dll

How to read specific numbers out of a file

I want to write a Lua script which will save and load my vars back into my program. I searched a bit in the Internet for code examples and now i have this:
--SetUp vars
accept = 1
strenght = 5
hp = 2
--create file
local f = assert(io.open("quicksave", "w"))
f:write(accept, "\n")
f:write(strenght, "\n")
f:write(hp, "\n")
f:close()
--Set vars to 0(simulate restart of program)
accept = 0
strenght = 0
hp = 0
print("accept: "..accept.." Strenght: "..strenght.." HP: "..hp)
--load in the saved vars
local f = assert(io.open("quicksave", "r"))
accept = f:read("*line")
strenght = f:read("*line")
hp = f:read("*line")
f:close()
print("accept: "..accept.." Strenght: "..strenght.." HP: "..hp)
This works fine for me, but how can I read only specific values from the file? For example: what should I do if i want to read out only the second line of the file (the var for strength)?
You can simply read and discard the first line:
--load in the second saved var
local f = assert(io.open("quicksave", "r"))
f:read("*line")
strenght = f:read("*line")
Nevertheless, I suggest you save your data as a Lua script that can be loaded with dofile. Something like:
return {
accept = 1,
strenght = 5,
hp = 2
}
Then you can load it into a local variable and read the fields you need:
local state = dofile("state.lua")
strenght = state.strenght

Unable to ingest data from flume to hdfs hadoop for logs

I am using following configuration for pushing data to hdfs from log file.
agent.channels.memory-channel.type = memory
agent.channels.memory-channel.capacity=5000
agent.sources.tail-source.type = exec
agent.sources.tail-source.command = tail -F /home/training/Downloads/log.txt
agent.sources.tail-source.channels = memory-channel
agent.sinks.log-sink.channel = memory-channel
agent.sinks.log-sink.type = logger
agent.sinks.hdfs-sink.channel = memory-channel
agent.sinks.hdfs-sink.type = hdfs
agent.sinks.hdfs-sink.batchSize=10
agent.sinks.hdfs-sink.hdfs.path = hdfs://localhost:8020/user/flume/data/log.txt
agent.sinks.hdfs-sink.hdfs.fileType = DataStream
agent.sinks.hdfs-sink.hdfs.writeFormat = Text
agent.channels = memory-channel
agent.sources = tail-source
agent.sinks = log-sink hdfs-sink
agent.channels = memory-channel
agent.sources = tail-source
agent.sinks = log-sink hdfs-sink
I got no error message, but still i m not able to find out the output in hdfs.
on interrupting I can see sink interruption exception & some data of that log file.
I am running following command:
flume-ng agent --conf /etc/flume-ng/conf/ --conf-file /etc/flume-ng/conf/flume.conf -Dflume.root.logger=DEBUG,console -n agent;
I had a similar issue. In my case now it's working. Below is the conf file:
#Exec Source
execAgent.sources=e
execAgent.channels=memchannel
execAgent.sinks=HDFS
#channels
execAgent.channels.memchannel.type=file
execAgent.channels.memchannel.capacity = 20000
execAgent.channels.memchannel.transactionCapacity = 1000
#Define Source
execAgent.sources.e.type=org.apache.flume.source.ExecSource
execAgent.sources.e.channels=memchannel
execAgent.sources.e.shell=/bin/bash -c
execAgent.sources.e.fileHeader=false
execAgent.sources.e.fileSuffix=.txt
execAgent.sources.e.command=cat /home/sample.txt
#Define Sink
execAgent.sinks.HDFS.type=hdfs
execAgent.sinks.HDFS.hdfs.path=hdfs://localhost:8020/user/flume/
execAgent.sinks.HDFS.hdfs.fileType=DataStream
execAgent.sinks.HDFS.hdfs.writeFormat=Text
execAgent.sinks.HDFS.hdfs.batchSize=1000
execAgent.sinks.HDFS.hdfs.rollSize=268435
execAgent.sinks.HDFS.hdfs.rollInterval=0
#Bind Source Sink Channel
execAgent.sources.e.channels=memchannel
execAgent.sinks.HDFS.channel=memchannel
I suggest using the prefix configuration when placing files in HDFS:
agent.sinks.hdfs-sink.hdfs.filePrefix = log.out
#bhavesh - Are you sure, the log file(agent.sources.tail-source.command = tail -F /home/training/Downloads/log.txt) keeps appending data ? Since you have used a Tail command with -F, only changed data(within the file) will be dumped into HDFS

Xdebug and Webgrind couldn't get to work

I installed xdebug and webgrind on windows xampp 1.7.7 using this link: link . On going to http:// localhost/webgrind gives something as below instead of showing profiled script.No dropdown menu or something to select.
Select a cachegrind file above
(looking in C:\xampp\htdocs\webgrind\tmp/ for files matching /^cachegrind.out..+..+$/)
But I have 2 files in tmp folder starting with cachegrind.out names.
My settings in (xampp/php/php.ini) are
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.2-5.3-vc9.dll"
xdebug.profiler_output_dir = "C:\xampp\htdocs\webgrind\tmp"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_name = cachegrind.out.%t.%p
webgrind/config.php settings
static $storageDir = 'C:\xampp\htdocs\webgrind\tmp';
static $profilerDir = 'C:\xampp\htdocs\webgrind\tmp';
I tried with these too
static $storageDir = '';
static $profilerDir = '/tmp';
But no result. How can I get it to work?
I got this accidentally, playing with values in xampp/php/php.ini file.
Here is the thing change value of xdebug.profiler_append from 0 to 1.
i had the same pb that took a long day having xampp 1.7.7 in my windows 7 OS i found that the
php_xdebug-2.2.2-5.3-vc9.dll was bad even it was php_xdebug-2.2.2-5.3-vc9.exe in the first download after a look at php.ini i found the good default xdebug just here with extra lignes so i delete the semi-colonnes ;
**[XDebug] zend_extension = "C:\Programs\xampp\php\ext\php_xdebug.dll"
xdebug.auto_trace
; Type: boolean, Default value: 0
; When this setting is set to on, the tracing of function calls will be enabled just before the
; script is run. This makes it possible to trace code in the auto_prepend_file.
;xdebug.auto_trace = 0**
; xdebug.collect_includes
; Type: boolean, Default value: 1
yes there was the good php_xdebug.dll coming with xampp
so use it and dont look far :) maybe that will help you
it might be also the matter of relative addressing due to portable xampp.
you can change your Xdebug addresses like this.
before
[XDebug]
zend_extension = "\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "\xampp\tmp"
after
[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "D:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "\xampp\tmp"