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…
Tag: linux
How to programmatically check whether a library dependent program can run in a Linux system?
I am having a program(binary) which depends upon libraries such as pthread, sqlite3,libcrypto and libcurl.I want to run this program in multiple user PCs.How to programmatically check whether the dependencies are met, before installing the binary? ./configure cannot be be used as it is for the purpose of buil…
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…
How to exclude print commands of python script in variable of shell script
I have a python script called spark.py. This scipt will be invoked using a shell script in Linux. The spark.py is like below: The shell.sh is like below In this shell script I am collecting the output of the spark.py as a variable. When I do so I am unable to see any print commands of the spark.py in the
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…
How to run node server and java server in same command line in package.json start
I need to run : And : I tried : Or But in both case the java server is not running when I ask it in the node applicaition. But if I run both commande in 2 differents console. There is no problem. Thank you Edit: I try to do it in the npm start Answer Ok so I found
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…
How to know when dd has finished
I have a issue with the dd comand. I use it in a while like this: And it works like charm, the only problem is that once the file is read completely, it doesnt stop the while, it stays there stalled. How could I make the while to stop once the dd read all the file? BTW: Note my machine
Linux shell temporary DNS
In a linux shell script, I want to change the dns address temporarily. To do this, I can insert temprary dns address into resolv.conf right after the shell run and remove it before the script ends. That’s it. But the problem is, all every other scripts also hit the address while the script is running. T…