In shell, how to group the numbers in $foo as 1-3,6-8,11,13-17 Answer As an alternative, you can use this awk command: Now run it as: Here is an one-liner for doing the same: In this awk command we keep 2 variables: p for storing previous line’s number s for storing start of the range that need to be pr…
How know SSL fingerprint for some website using Linux CLI?
I’m trying update (using esp8266 microcontroller), update a DNS record hosted on DigitalOcean, using the API. How do I do to get HTTPS fingerprint using Linux CLI, for use on my code? Answer If you are using ESP (arduino IDE) library WiFiClientSecure.h, you need declare the “const” variable …
Error When trying to push ssh keys into github from bash script
I am working on a script that creates ssh keys and puts them into github using bash. I am running into this error when running this function.. I want a way to generate ssh keys and put them into github from terminal within my script. Error: { “message”: “Bad credentials”, “docume…
Capture a set of numbers in sed
I have the following string I am trying to capture only v2010.0_1.3 using and I get the following result v2010.0_1.3 Tue Jun 6 14:38:31 PDT. It looks like sed is not stopping the first occurrence of the space, but at the last one. How can I capture only until the first occurence? Answer Using sed sed’s …
How can I hook c function from ELF file, that uses library .so in Linux ?
I have executable ELF file, that uses library lib.so, and this ELF invokes function Func1 from lib.so I need to hook this function, so it will be replaced with my function, that does something else. How can I do this without changing this executable file ? Answer Take a look at LD_PRELOAD. That environment va…
socket recv function not returning updated value
Trying to create socket application using c (Linux) to constantly fetch data from a server For this I have created a loop and inside it the routine connects , send a command, receive some data and close the socket. It works fine for the first interaction but looks like the recv function failing to update the …
DKIM key not valid – Bad RSA signature
I have setup DKIM on a Ubuntu 14.04 machine using opendkim and postfix. I generated the RSA keypair and updated the TXT record. When testing the settings at any DKIM tester like www.mail-tester.com or www.dkimvalidator.com, I get errors like “result = fail, bad RSA signature”. Here is an example m…
Signal Handling C programming on ubuntu
While I sending kill -9 command to a program on ubuntu , I want to close other running processes before the program closes.I am trying this with c programming . Could it be something like this? How can I say program if you get KILL command you should do something? Answer Per the POSIX standard <signal.h>…
Python paramiko executing sudo
I am using paramiko put method to send file from local to remote server. However, I am having problem executing sudo su – user command to view the file from remote. I also tried changing the permission from local but the file permission stays intact when transferred. Is there a way to execute sudo su &#…
Does an argument after a redirection do anything?
Is any argument after a redirection ignored, or does it have any unintended consequences? I was surprised to find that a typo I made in my bash script made absolutely no difference because it was specified after a redirect. E.g. I expected it to complain about something like this But it doesn’t throw an…