print text between 2 pattern when find a match inside - sed

for one of my script i need to print text between 2 pattern when a match if found inside, i dont find how to make it simple.
the content of the file is:
===== seble dom0 report =====
IP address: 10.42.0.100
location: slot-3.enclosure-43.eqx
ID: infra-dom0.dom0.seble
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU E5-2660 v3 # 2.60GHz
===== arnica dom0 report =====
IP address: 10.1.42.46
location: slot-3.enclosure-12.eqx
ID: infra-dom0.dom0-3
Xen-Version: 4.1
CPU: AMD Opteron(tm) Processor 6174
===== sithtemd dom0 report =====
IP address: 10.1.42.191
location: slot-13.enclosure-7.vty
ID: infra-dom0.mutu119
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU X5670 # 2.93GHz
if i seach enclosure-7 for exemple i would like it return :
===== sithtemd dom0 report =====
IP address: 10.1.42.191
location: slot-13.enclosure-7.vty
ID: infra-dom0.mutu119
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU X5670 # 2.93GHz
It's a mix between a grep and a sed -n "/===== /,/^$/p" but can't find it...
Thanks in advance for your answers :)

This is the answer:
perl -0777 -lne 'print for grep /enclosure-7/, /^=====.*?^$.*?\n/mgs' file.txt

p will be treated as a regular expression
awk -v p='enclosure-7' -v RS= '$0~p' file.dat
Empty RS means that records are separated by one or more blank lines and nothing else.

With sed:
sed '/^=====/{:a;N;/\n$/!ba;/enclosure-7/!d}' file

Related

Run mini-httpd serveron linux

i just installed mini-httpd on linux mint.
but can'n connect to localhost / 127.0.0.1 on browser
server is working
● mini-httpd.service - LSB: mini-httpd start script
Loaded: loaded (/etc/init.d/mini-httpd; generated)
Active: active (exited) since Sat 2022-02-05 14:33:10 EET; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 6236 ExecStart=/etc/init.d/mini-httpd start (code=exited, status=0/SUCCESS)
and this is the config file
# Example config for mini_httpd.
# Author: Marvin Stark <marv#der-marv.de>
# Author-Update: 2015 Jose dos Santos Junior <j.s.junior#live.com>
# Description Update: Changed the default document root (data_dir)/var/www/html
# Last-Update: 2015-09-05
# Uncomment this line for turning on ssl support.
#ssl
# On which host mini_httpd should bind?
host=localhost
# On which port mini_httpd should listen?
port=80
# Which user mini_httpd should use?
user=nobody
# Run in chroot mode?
#chroot # yes
nochroot # no
# Working directory of mini_httpd.
#dir=<work_dir>
# We are the web files stored?
# Please change this to your needs.
data_dir=/var/www/html
# CGI path
cgipat=cgi-bin/*
# Which certificate to use?
#certfile=<certfile>
# Which logfile to use?
logfile=/var/log/mini_httpd.log
# Which pidfile to use?
pidfile=/var/run/mini_httpd.pid
# Which charset to use?
charset=iso-8859-1
Use
apk add curl
curl http://localhost
to test the web server.
see this Wiki
Make following changes in config file
# On which host mini_httpd should bind?
# host=localhost
# Which user mini_httpd should use?
# user=nobody
# Run in chroot mode?
chroot # yes
# nochroot # no
In etc/default/mini-httpd make
START=1

Concourse CI Windows Worker

I'm trying to setup a Concourse CI environment with a Windows 7 worker.
I have one machine under Ubuntu Server (16.04) hosting my TSA server and one worker (for the support of git resources), and a second one under Windows 7 hosting a worker.
Everything seems to work fine as:
I can login into the web ui
the fly -t my_concourseci workers command returns :
name containers platform tags team state version
ubuntu 1 linux none none running 1.1
windows7 0 windows none none running 1.1
the fly -t my_concourseci execute -c test.yml command returns:
executing build 146
initializing
running echo Hello World!
Hello World!
with the following content in test.yml file:
platform: windows
run:
path: echo
args: [ "Hello World!" ]
Nevertheless when I add an input to my task:
platform: windows
> inputs:
> - name: concourse
run:
path: echo
args: [ "Hello World!" ]
I get the following error:
executing build 148
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5698k 0 5698k 0 0 1948k 0 --:--:-- 0:00:02 --:--:-- 1949k
initializing
failed to stream in to volume
errored
If I look at the windows worker log I got this error that comes up:
{"timestamp":"1500642862.643555164",
"source":"baggageclaim",
"message":"baggageclaim.api.volume-server.stream-in.bad-stream-payload",
"log_level":1,
"data":{"error":"tar extract failed (exit status 2). output: \"\\ngzip: stdin: not in gzip format\\n/usr/bin/tar: Child returned status 1\\n/usr/bin/tar: Error is not recoverable: exiting now\\n\"",
"session":"2.1.8730",
"volume":"15bf1fc6-0727-4962-6c84-18446e54ab96"}
}
Any ideas about what can cause a not in gzip format error ? Knowing that if I run the exact same task on a linux platform every works fine.
platform: linux
image_resource:
type: docker-image
source: {repository: busybox}
inputs:
- name: concourse
run:
path: echo
args: [ "Hello World!" ]
----- STDOUT
executing build 149
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5699k 0 5699k 0 0 1917k 0 --:--:-- 0:00:02 --:--:-- 1918k
initializing
Pulling busybox#sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4...
sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4: Pulling from library/busybox
9e87eff13613: Pulling fs layer
9e87eff13613: Verifying Checksum
9e87eff13613: Download complete
9e87eff13613: Pull complete
Digest: sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4
Status: Downloaded newer image for busybox#sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4
Successfully pulled busybox#sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4.
running echo Hello World!
succeeded
Thanks.
Launch powershell as Administrator, and run the concourse_worker.exe from there. That worked for me.
I am running a Windows Server 2016 Base on AWS based on this AMI ami-e1876a98
Thanks for your answers, it helps me solve my problem.
I were starting my concourse worker within a MSYS 1.0 environment. The thing is that MSYS contains tar and gunzip binaries within the $PATH. When I started concourse worker inside a Power Shell or cmd.exe without any MSYS unix-like binaries in the $PATH it worked like a charm !
Note: Be sure to have no MSYS binaries in the $PATH Windows environment variable for this to work, especially check that Git-Bash environment tools are not added to your windows $PATH environment variable.
Thanks again.

Raspberry pi GPIO value is always 0

I'm trying to change the value of GPIO port manually.
To change the value of gpio18 (physical port 12), I did as follow:
# gpio unexportall
# echo 18 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio18/direction
# cat /sys/class/gpio/gpio18/value #output is 0
# echo 1 > /sys/class/gpio/gpio18/value
# cat /sys/class/gpio/gpio18/value #output is 1
For gpio7 (physical port 26) I perform the exact commands as above. But the value remains 0:
# echo 7 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio7/direction
# cat /sys/class/gpio/gpio7/value #output is 0
# echo 1 > /sys/class/gpio/gpio7/value
# cat /sys/class/gpio/gpio7/value #output is 0 again
I've tried with all other gpio ports. All ports function properly except gpio7 and gpio11 (the value is always 0).
By the way before using this raspberry pi, I was working with another raspberry pi2. Strangely the gpio7 in the previous raspberry pi had the same problem too. Is it a hardware problem or I am doing something wrong?
EDIt: I have also used Wiringpi and J4Pi, the result is the same.

gentoo at vmware, DnD and resizing aren't working

Drag and Drop isnt work, resizing too. Only copy-paste is work sometimes.
I thought that it is becouse vmblock errors, but after "emerge vmware-modules" vmblock errors gone and problem still exists.
Host OS - Windows.
al .cache # equery list -i xorg-server
* Searching for xorg-server ...
[IP-] [ ] x11-base/xorg-server-1.16.4:0/1.16.1
al log # lsmod | grep vm
vmblock 9176 0
vmci 57829 0
al log # eselect kernel list;
Available kernel symlink targets:
[1] linux-4.1.12-gentoo *
al log # ls /usr/src;
linux linux-4.1.12-gentoo
al vmblock # ls /proc/fs/vmblock
dev mountPoint
http://pastebin.com/jKSFqzrU
http://prntscr.com/9f6qzx
http://prntscr.com/9f6r4k
http://pastebin.com/ZcAa5CWG
http://pastebin.com/4AZRZPL8
http://pastebin.com/gDdn3FG5

What uses the memory on raspberry pi?

On my pi after start there is no free memory, but i can not found, waht uses it:
pi#node1 ~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 2.00
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2708
Revision : 0013
Serial : 00000000bf2e5e5c
pi#node1 ~ $ uname -a
Linux node1 4.0.7+ #801 PREEMPT Tue Jun 30 18:15:24 BST 2015 armv6l GNU/Linux
pi#node1 ~ $ head -n1 /etc/issue
Raspbian GNU/Linux 7 \n \l
pi#node1 ~ $ grep MemTotal /proc/meminfo
MemTotal: 493868 kB
pi#node1 ~ $ grep "model name" /proc/cpuinfo
model name : ARMv6-compatible processor rev 7 (v6l)
pi#node1 ~ $ ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5
0.6 0.2 6244 2377 -bash
0.3 0.0 6748 2458 sort -k 1 -nr
0.3 0.0 4140 2457 ps -eo pmem,pcpu,vsize,pid,cmd
0.2 0.1 9484 2376 sshd: pi#pts/0
0.2 0.1 5600 2236 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 104:107
pi#node1 ~ $ free
total used free shared buffers cached
Mem: 493868 478364 15504 0 500 4956
-/+ buffers/cache: 472908 20960
Swap: 102396 116 102280
I am not a linux expert, but if I understand it right, there is just 15Mb free memory, but no task uses more than 0.6%. Than why is not there more free?
Memory is not exclusively allocated by Processes.
The bootloader and the init ram filesystem is stored in memory.
The kernel (could be very big) is loaded into memory.
The kernel reserve memory for it's processes. ps shows 0.0% for these system processes.
Driver allocate buffer memory
The graphics card needs memory
If you have not configured your swap space on a harddrive or SD card, it uses memory.
The network system allocates memory for unix sockets and shared memory.
100 processes with 0.1 % are 10%.
And, if you start a process and stop it not all of it memory will be released.
Try it. Show the memory usage with free. Start a process that need some memory. Stop the process and use free again. I would bet that there is more memory usage than before.
Edit
Here is an example of a pi with less memory usage. I have no problems running java on it. I have a WLAN Dongle and a original NOIR CAM installed.
I installed Raspbian Wheezy. I used a kernel that I compiled from sources:
> uname -a
Linux raspberrypi 3.18.14+ #2 PREEMPT Sun May 31 20:19:04 UTC 2015 armv6l GNU/Linux
> head -n1 /etc/issue
Raspbian GNU/Linux 7 \n \l
On this pi I can run java -version in an acceptable period of time.
time java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)
real 0m1.012s
user 0m0.800s
sys 0m0.190s
Here is my memory footprint
> free
total used free shared buffers cached
Mem: 380816 138304 242512 0 8916 96728
-/+ buffers/cache: 32660 348156
Swap: 102396 0 102396