I am using docker containers and I have mounted host /proc to container /host/proc. Now I want ps command inside docker container to look for processes into /host/proc instead of /proc. or how can I right similar utility to ps Answer the /proc path is hardcoded in the source tree of the /bin/ps binary file. T…
Tag: linux
Jsch running a remote jar with combined tail command is not working properly
I am trying to run a number of standalone spring boot jars on a remote linux server(on different ports) over SSH with JSch. I use tail on my command, because i need tomcat server logs. When i start service that runs standalone jars, some jars is not running. Here is a sample script that i use to run standalon…
Using a signal handler to process datas received from a fifo
I am writing a simple client/server communication with fifo but i am stuck at using a signal handler to process client request. The server open a fifo in readonly and non blocking mode, read datas received and writes back some datas to the client fifo. And this actually works fine when there is no signal hand…
rrdtool graph: one graph line plotted incorectly
I’m trying to keep track of the CPU temperature and usage and then create a graph with the values. I used the rrdtool to store and create the graph. Here is the command I used to create: then to insert values: if I query the data, it looks like this: To create the graph I use this: The temperature line
SSH and exec channels with python shell
We have implemented a python shell for our hardware devices that solely consists of the python cmd module on embedded linux. Our (non-root) user’s shell is set to the path of this python shell in /etc/passwd and /etc/shadow. Code example below: Previously, one of our clients had used SSH.NET to issue co…
Finding an exact match in QNX without using grep -w
I’m writing a script that needs to find an exact match in a file that is compatible with QNX and POSIX compliant Linux more detail: Im trying to find the user of a process so the original command I wrote was which works perfectly in POSIX compliant Linux however, QNX isn’t totally POSIX compliant …
How to have simple and double quotes in a scripted ssh command
I am writing a small bash script and want to execute the following command via ssh Unfortunately this command contains both simple and double quotes so I can’t do What would be the recommended way to solve this issue ? Answer Using a heredoc You can just pass your exact code on the shell’s stdin: …
Alternate to setpriority(PRIO_PROCESS, thread_id, priority)
Given – Thread id of a thread. Requirement – Set Linux priority of the thread id. Constraint – Cant use setpriority() I have tried to use below pthread_setschedprio(pthread_t thread, int prio); pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param); Both the abo…
Checking result of executed command in a Bash script
I want to run my VirtualBox after my I logged in. To do that, I have to check if it’s already running or not. If not, then start the VM. My problem is that I can not put the result of VirtualBox command into a variable in Bash. I’ve created a function to get the exit parameter, but I get
Check if line starts with digit then put those lines in a separate file using Bash
I would like to check in bash if line starts with digit then put those lines in a separate file. I tried ^[[0-9]] but it doesn’t work. Here is the code which I tried: Answer The correct operator to use regex in Bash script is =~. Moreoever you don’t need to double [ in range of characters. Try thi…