Skip to content

Tag: linux

Script terminates when storing grep -c output when value is 0

I am trying to check if a file has CR line feed and store the result 0 or 1 into a variable. Here is my command that runs inside a script. The script runs until the previous line and doesn’t run this line but terminates abruptly. Inside an echo statement it works perfectly. This prints isCR=0 or isCR=1 …

alias with bash involving current system time

I have the problem with macOS mojave, but I guess it generalizes to all bash environment. In the .bashrc or .profile, I add one line as: My purpose is to send the current system time as a message when commiting a change by typing gc. However, the system time was read when alias was invoked (here is when I log

Live555 RTSP server does not use UDP

I have a pretty basic live555 RTSP server and client to stream a h264 stream written in c++. Here’s the code I have for the client (adapted from testProgs/testRTSPClient.cpp, bundled with live555) Here’s the code I have for the server (adapted from testProgs/testOnDemandRTSPServer.cpp, bundled wit…

Why can’t I sudo echo a line in /etc/?

I am on centos and I did sudo echo ‘testline’>>/etc/test/test it said -bash: /etc/test/test: Permission denied However, when I do sudo vi /etc/test/test and insert testline and do :wq it writes out fine, why is this happening? Answer You need to wrap the whole statement (including the redire…

Redirect STDERR to a file from Perl in Linux

So, I was trying to catch the error messages from running some basic Linux command, using Perl. For example, I try to catch the STDERR when running the ldd command: But, even if the output of the ldd command does contain error messages such as ldd: warning: you do not have execution permission for, it won&#82…

python filter lines matching keyworks

I have working python script producing following output. Script output Now i want want any line starting with stream in output so i am using following logic but its not working. Answer Your data is a massive string instead of a list of strings as you expected. Also it’s easier to use str.startswith inst…

Why only the parent process takes input?

I created a program that forks and asks for input: I run it and enter one number: Why does it appear that only the original parent process gets a number? Why isn’t the output instead e.g.: Answer All of the processes accept input. The problem is that only one can do so at a time. Which process is gettin…

How to switch from terminal back to editor in vim?

I am new to vim, and I learn that you can interact with the terminal two ways while in vim. The first is to type: ! . The second is :term, when you have a terminal side by side with your source code. As soon as I press :term, my cursor is in the terminal. How do I switch back