I am doing a linux script to extract which users are logged onto a machine, from where, and how long they have been idle. So far I have been using the “w” command in linux. However I now noticed that it truncates usernames and source I have three users logged on testuser testuser-new lala-testuser…
Use linux perf utility to report counters every second like vmstat
There is perf command-linux utility in Linux to access hardware performance-monitoring counters, it works using perf_events kernel subsystems. perf itself has basically two modes: perf record/perf top to record sampling profile (the sample is for example every 100000th cpu clock cycle or executed command), an…
How to store value from grep output in variable
I am working on one bash script, in which I have to use the regular expression to match string and then store the output in a variable to reuse it. here is my script, I tried this many ways, but I am getting error : ./check.sh: MET-3-get-issue-id-from-branch-name: not found if I run individual grep command th…
Is it safe to assume memory page size is a power of two?
I am currently working on a portable C program which makes use of the memory page size (as returned by sysconf(_SC_PAGESIZE)). I know most often page size is a power of two to allow efficient management using bitwise operations; I found no guarantee of this anywhere, though. So how safe is it to assume page s…
client stops connecting to server after 2-3 successful connections. socket programming in c
I am trying out simple client-server program using socket programming in c. The program works fine when I execute server first and then client but after two to three successful executions, the client stops connecting to the server. This again starts working if I execute the programs after a certain amount of …
How to kill a process in a system call?
I found out that sys_kill can be used to kill process from a system call, but when i compile the following code, i get the following error: Answer It is often not possible to call the entry point of a system call from the kernel, since the API is for use from user space. Sometimes the functionality is provide…
Calculating a sum of numbers in C shell
I’m trying to calculate a sum numbers positioned on separate lines using C shell. I must do it with specific commands using pipes. There is a number of commands: comand.. | comand.. | (comands…) printing lines in the following form: The result should be 22, since 1 + 2 + 8 + 4 + 7 = 22. I tried &#…
datanode[slave] running but connect namenode[master]
i can start hadoop sucess but datanode[slave] can’t connect namenode[master] detail /etc/hosts core-site.xml and hdfs-site.xml Answer 1) check if firewall is restricting port if so, flush it To open 9000, 2) check namenode logs for any issues under /var/log/hadoop
Netbeans Cpp compiles and runs project, but not test with cppunit
I have a C++ project using libraries such as wiringPi and MySQL Connector. My regular project compiles normally when I run it. When I try to Test one of my tests, it fails building the project. Here’s the output: The tests used to work before the implementation of the DatabaseAdapter & SerialDriver …
How to run a python script with Raspberry Pi until we stop it manually
Currently I am working with both Raspberry Pi and Arduino at the moment. For Arduino in some cases, if we start running the script, then it will run until we stop them manually. I am wondering if there is a way to do the same with a Raspberry Pi when using it with Python. For Raspberry Pi, when I use,