Skip to content

space issue between Month and date in linux

In my linux system date is having two space between month and date(ex:Jun 4) .so i used date command(ex:date +’%b %_d %H’) and stored the value in variable that time i am getting only one space between month and date(ex:Jun 4), so please help me to get the actual system format while using variable…

Get hardware information from /proc filesytem in Linux

I use execv to run lshw command to get the CPU, disk, and memory in C code. But I would like to search another solution to get these information from /proc or any other existed data. Have any suggestion? Here is my code: Linux command: $ sudo lshw -short -c disk -c processor -c memory I have two questions: Wh…

Reading a string, char[] until end of line C

I need to read a file name, but I want my code working for names contains space. How to read until end of line from keyboard? My code: Answer Read carefully the documentation of fgets(3) (which might be locally available on your Linux computer with man fgets) fgets() reads in at most one less than size charac…

Automatically close PuTTY when connection is lost

I have a script in bash, running multiple PuTTY sessions. For example, I open the connection to run a couple of commands, when it finishes it saves the values, closes the session, opens a new session and runs a couple more. This script is supposed to run for 60 hours, more or less, so i need to have everythin…

Need to run .jar from console for it to work

I have a java application. I’m using eclipse to write, compile and create a runnable .jar. The program is used to discover OCF devices. It uses UDP and multicast. Multicast code The code works when I start it from eclipse. It also works when I run the .jar from console on Linux. But when I start it with…