I have a piece of python code that calls a binary via the subprocess module. This binary reads data from stdin and outputs other data to stdout, which should then be collected by the python code. Here’s how I use this binary in a shell: with a return after each line (including the last), from which I ge…
Tag: linux
Linux executable fails using javafx-maven-plugin
I have a multimodule maven project with JavaFX up and running. I can create an jar file containing all classes that is executable through a maven assembly, so I know the packaged bundle works. For conveniance I want to create a native bundle/executable using the javafx-maven-plugin This works fine on Windows,…
Possible to combine glob sort w/ alternation in zsh?
Looking for a shell-only[1] way to take this list of dirs: And return it sorted numerically, with the subdirs showing up right after their parent: (*|*/bar)(n) is rejected as a bad pattern, while */{,bar}(n) expands to */(n) ~/bar(n) so the subdirs show up at the end. [1] I need this to be able to work on a w…
Use php exec to launch a linux command with brace expansion
How can I force the php exec() to interpret the linux brace expansion? I am encountering a strange behavior, and did not find a way to fix it the way I want. I want to execute a linux command containing brace expression to select a batch of files, from php I am using php to generate a “random” num…
How to get numeric keypad arrows working with java applications on Linux
The arrow keys on the numeric keypad do not work with Java applications on Linux. Strangely enough, the Home, End, PgUp, PgDn, Ins, Del all work. This is especially annoying when using Intellij for programming. How do you get the arrow keys working? Answer Physical keys on a keyboard are mapped to key codes u…
gsub encoding error when running on Linux Docker Container Invalid byte sequence in US-ASCII
I have a string I’m converting from “rn” to “n” line ends using: When I run it on my Windows host, it works fine. When I run on my Linux host, in a docker container, I get this error: I am running Ruby 2.2. Answer I fixed it by doing this Invalid byte sequence in UTF-8 (ArgumentE…
linux – serial port programming ( ASCII to Byte )
I tried to receive data from serial port. However, those data is unrecognized to me. The root cause is because those are in ASCII. To decode the data, it needs to be the byte formate. The buffer I’ve created is unsigned char [255] and I try to print out the data by using Two questions here: The data mig…
grep usage for date in a text file
I have some data in a text file like below: Now i want to fetch CPU Usage/Timestamp pair at a time like below: And, Memory Usage/Timestamp pair at a time like below: I tried grep -i “CPU Usage” testFile.txt | grep -i “Timestamp”, but it fetched the complete data irrespective of CPU Usa…
Retrieve string between characters and assign on new variable using awk in bash
I’m new to bash scripting, I’m learning how commands work, I stumble in this problem, I have a file /home/fedora/file.txt Inside of the file is like this: What I wanted is to retrieve words between “[” and “]”. What I tried so far is : I can print the words between “[…
How to get the returned stdout of a program called with QProcess?
I am writing a program in Qt and currently using popen to run a linux command and read the output into a string: So I’d like to throw the above code away as I’d prefer to use higher level facilities provided by Qt if possible. Does anyone have an example of how to do this with QProcess or atleast …