Skip to content

Tag: linux

Why does bash go into an infinite loop?

I was trying out different ways of emulating a boolean variable in bash. One method is: which prints true and false respectively. Then I had a brain cramp and typed: expecting to see yes in the terminal. However, without the echo command, it went into an infinite loop printing y. Can someone explain what bash…

Extracting group from regex

I am new to using regex and having some issues understanding how to extract a group from a regular expression. I have a text file (example.txt): I am trying to extract the “5.2.1” only from the libpackage line and put it into a variable for a bash script. I have tried doing But it gives me the ent…

How to keep telnet connection alive from client side

I have a device as a telnet server but drops the connection if no packet is received in 60 seconds, for some reason this behavior cannot be changed. Putty has a feature to send null packets to the server periodically to keep the session alive, which works fine for me. But some times I have to telnet to the de…

Python Subprocess ping -h Returns Exit Status 2

I want to capture ping -h output using Python, it results in exit status 2. I am working on a Linux host. This is the output The command seems to execute normally on the shell. What is the cause of this error? How can I fix it? Answer Following Barmar solution It is a normal behavior for ping, but the