[Solved] How to get my external ip (primary interface) without internet connection, without eth0 and without any hardcoded constnts using C [closed]

If you just want to discover the default adapter’s assigned IP address, e.g. 192.168.0.237, call getifaddrs and enumerate each address. This is the same list of adapters that ifconfig would normally display with associated information for gateway and netmask. Filter out the ones that are flagged as IFF_LOOPBACK or don’t have IFF_UP. Some sample code … Read more

[Solved] How can I query the number of the virtual desktop on which the bash script is running in Linux Mint via bash?

Based on answer of KamilCuk, its possible to output on follow way the line which is including the number of the active desktop: nr_of_active_desktop=activedesktop=$(wmctrl -d | grep “*” | rev | cut -d ‘ ‘ -f1) echo $nr_of_active_desktop solved How can I query the number of the virtual desktop on which the bash script is … Read more

[Solved] Linux ‘cut’ command line and replace

This should do the trick: #!/bin/bash INPUT=”$@” SIZE=${#INPUT} for ((i=0; i < ${SIZE}; i++)); do echo “${INPUT}” INPUT=”${INPUT:0:${i}} ${INPUT:$((i+1)):${SIZE}}” #INPUT=”$(echo “$INPUT” | sed “s/^\(.\{${i}\}\)./\1 /”)” done I added a sed option in the comment, although it creates a sub-process when you don’t really have to. 0 solved Linux ‘cut’ command line and replace

[Solved] Python script looking for nonexistent file

Check the root variable. You might be looking for the file at ./access_log-20150215 that is actually in a subdirectory such as ./subdir/access_log-20150215. If you want to explore all subdirectories use f=open(os.path.join(root,file),’r’) but if you only want the top directory you can use os.listdir(‘.’) 3 solved Python script looking for nonexistent file

[Solved] Undefine reference of

The problem is that c++ test.cpp -I./include-core/ -o bin/test -L./bin -l${core_NAME_ROOT}c++ test.cpp -I./include-core/ -o bin/test -L./bin -l${core_NAME_ROOT} will first process the library and then your .cpp file. When processing a library, referenced symbols are resolved (“linked”) and all unresolved symbols in the library that aren’t needed are thrown away. That means that as soon as … Read more

[Solved] Splitting comma set files

This might work for you (GNU sed): sed -r ‘s/^(.*\|.*\|)([^,]*),([^|]*)(\|.*\|.*\|)([^,]*),([^|]*)(.*)/\1\2\4\5\7\n\1\3\4\6\7/;P;D’ file Iteratively split the current line into pieces, building two lines separated by a newline. The first line contains the head of the 3rd and 6th fields, the second line contain the tails of the 3rd and 6th lines. Print then delete the first of … Read more