samedi 9 mai 2015

Same commands, different results

I saw a weird behavior in my bash terminal. I run same commands on my terminal command line, but get different results. Following lines are copied-pasted from my bash terminal windows:

me@me:~$ ls "/media/me/My Passport/Archive U/‌"
ls: cannot access /media/me/My Passport/Archive U/‌: No such file or directory
me@me:~$ ls "/media/me/My Passport/Archive U/‌"
Backup  Documents  Downloads  Music  Pictures  Videos

I tried both commands using up arrow key (to bring previous commands to the current line) many times and the result does not changes. To be sure that the command has no hidden character, I selected both commands and pasted it to an spreed sheet and converted each character to its code and compared. there was no difference. I tried to select each commands and right-click, choose Copy, right click again, choose paste. If I copy-paste first command, I get first result. I f I copy-paste second command, I get second result!!!

Could any one say what is the difference between two commands? I guess no one could!

I tell you what is the difference. First command is copied and pasted from a text file!

I am using Ubuntu 14.04.

How to run tkinter based app directly by starting X in Debian

I have a Debian OS, and I have a tkinter based python code.

I want to run this tkinter based app automatically when I run startx without seeing desktop.

How can I manage this?

Thanks,

How to increase the EXT4 timestamp precision in linux?

Timestamp precision or accuracy of EXT4 filesystem in Linux is one second ( Windows timestamp precision is 100 nano second ). But our application which is running on cloud requires more precision for the filesystem . How to increase the timestamp precision in Linux ?

spring-security-core 2.0.3 spring-aop 2.0.8 cause NoSuchMethodError

Using Maven to build my project under windows works fine, but when deploy it to Linux servers via bamboo, on two servers it seems ok but on third server I get a NoSuchMethodError regarding one of the spring libs. İf i remowe spring-aop:jar from war it works. İf it is because of different spring versions how to works on other two linux servers?

Has anyone come across this problem before, or have any advice on how I can debug this error further?

Any help would be appreciated.

library tree

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ pqis-op ---
[INFO] com.toyotatr.tmem.pqis:pqis-op:war:0.0.1.7-SNAPSHOT
[INFO] +- com.toyotatr.tmem.pqis:pqis-service:jar:0.0.1-SNAPSHOT:compile
[INFO] |  +- com.toyota.tme.jpa:jpa-support:jar:1.1tk:compile
[INFO] |  +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] |  |  +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] |  |  +- org.hibernate:hibernate-commons-     annotations:jar:3.1.0.GA:compile
[INFO] |  |  +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] |  |  |  \- antlr:antlr:jar:2.7.6:compile
[INFO] |  |  \- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |     \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
[INFO] |  |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  |  \- javassist:javassist:jar:3.4.GA:compile
[INFO] |  +- aspectj:aspectjrt:jar:1.5.3:compile
[INFO] |  +- aspectj:aspectjweaver:jar:1.5.3:compile
[INFO] |  +- cglib:cglib:jar:2.2:compile
[INFO] |  |  \- asm:asm:jar:3.1:compile
[INFO] |  +- javax.activation:activation:jar:1.1:compile
[INFO] |  +- javax.mail:mail:jar:1.4.2:compile
[INFO] |  \- net.sf.ehcache:ehcache:jar:1.5.0:compile
[INFO] |     +- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO] |     \- net.sf.jsr107cache:jsr107cache:jar:1.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.5.6:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.6:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- org.springframework:spring:jar:2.5.6:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] +- org.springframework:spring-core:jar:2.5.6:compile
[INFO] +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] +- org.springframework:spring-test:jar:2.5.6:test
[INFO] +- org.springframework:spring-webmvc:jar:2.5.6:compile
[INFO] |  +- org.springframework:spring-context-support:jar:2.5.6:compile
[INFO] |  \- org.springframework:spring-web:jar:2.5.6:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- javax.servlet:jstl:jar:1.1.0:compile
[INFO] +- javax.servlet:jsp-api:jar:2.0:compile
[INFO] +- taglibs:standard:jar:1.1.0:compile
[INFO] +- opensymphony:sitemesh:jar:2.4.2:compile
[INFO] +- org.springframework.security:spring-security-core-tiger:jar:2.0.3:compile
[INFO] |  \- org.springframework.security:spring-security-core:jar:2.0.3:compile
[INFO] |     +- org.springframework:spring-aop:jar:2.0.8:compile
[INFO] |     +- org.springframework:spring-support:jar:2.0.8:runtime
[INFO] |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:2.0.3:compile
[INFO] |  \- org.springframework.security:spring-security-acl:jar:2.0.3:compile
[INFO] |     \- org.springframework:spring-jdbc:jar:2.0.8:compile
[INFO] |        \- org.springframework:spring-dao:jar:2.0.8:compile
[INFO] +- org.json:json:jar:20140107:compile
[INFO] +- displaytag:displaytag:jar:1.2:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- commons-lang:commons-lang:jar:2.3:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] |  \- org.slf4j:jcl104-over-slf4j:jar:1.4.2:compile
[INFO] +- com.lowagie:itext:jar:2.1.7:compile
[INFO] |  +- bouncycastle:bcmail-jdk14:jar:138:compile
[INFO] |  +- bouncycastle:bcprov-jdk14:jar:138:compile
[INFO] |  \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
[INFO] |     +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
[INFO] |     \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
[INFO] +- junit:junit:jar:4.10:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] \- c3p0:c3p0:jar:0.9.1:compile
[INFO]

error

[07-05-2015 15:41:27:928] ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext() - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext-main.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:788)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:434)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:780)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:284)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:732)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:282)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:214)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:764)
    at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:145)
    at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
    at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:145)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:557)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:232)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
    at org.eclipse.jetty.server.Server.start(Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
    at org.eclipse.jetty.server.Server.doStart(Server.java:290)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1250)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
    at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser$AopAutoProxyConfigurer.configureAutoProxyCreator(AnnotationDrivenBeanDefinitionParser.java:109)
    at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:80)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    ... 53 more

Error compiling c++ windows code in debian

I am new in using Debian with xfce and I want to compile a c++ code which require windows api. The error is windows.h is not found.

How can I run this code in debian:

#include <iostream>
#include <windows.h>

using namespace std;

int main(void) {

    int life = 100;

    HWND hWnd = NULL;

    while (hWnd == 0)
    {
        hWnd = FindWindowA(0, "MyApp");

        cout << "Waiting for Rastalia Fantasy ..." << endl;
        Sleep(200);
        system("cls");
    }

    if(hWnd != 0)
    {
        DWORD PID;
        GetWindowThreadProcessId(hWnd, &PID);
        HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, false, PID);

        while (true)
        {
            if(!hProc) {
                cerr << "Cannot open process." << endl;
                break;
            } else {
                if(GetAsyncKeyState(VK_LCONTROL))
                {
                    int lifeResult = WriteProcessMemory(hProc, (LPVOID)0x00857D30, &life, (DWORD)sizeof(life), NULL);

                    if(lifeResult > 0){
                        clog << "Life changed." << endl;
                    }
                }
            }
        }

        CloseHandle(hProc);

        cin.get();
    }

    return 0;
}

I have installed mingw32 and wine but when I start, the program don't found MyApp.

HP Fortify analysis results, system() command injection

I am trying to write c++ code that calls a command in a linux command line and I am using HP Fortify to check for exploits in the code. Can someone familiar with HP Fortify source analyzer tell me if it is possible to use a system() linux call in c++ code without getting the low threat warning from HP Fortify (low : Command Injection: semantic)? Is there still a threat of command injection if I hard code the input to the system() function while writing out full paths to the programs and/or files in the call? I don't understand a more secure way of giving it input than hard coding it in. Should I be ignoring the system() function and find another way to call commands from my c++ code to the linux command line?

Edit: I tried using execv() instead of system() to call a program but it still gives me the command injection warning for using execv().

How to add a name to namespace

Dear all:
  As i kown, i can use the "clone" to create a process and a namespace, but the namespace created in this way has no name. For example, i create a network namespace with the parameter: CLONE_NEWNS, but in the command "ip netns list", there is no namespace list because the namespace created has no name. But i can use the command "ip netns add xxx" to create a namespace with the name "xxx".
  I wonder how to create a namespace with name using system call "clone".
  Thankyou verymuch for anyone's reply.

Best regards,
Vinllen

cpu load different to extract with python

I'm using psutil to remove the CPU load with python.

My problem is that with "top" in Linux shows:

    top - 11:45:52 up 12:39,  1 user,  load average: 0.07, 0.07, 0.09
Tasks:  58 total,   1 running,  57 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.4 us,  0.1 sy,  0.0 ni, 99.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   2097152 total,   315124 used,  1782028 free,        0 buffers
KiB Swap:   524288 total,        0 used,   524288 free,   139628 cached

In python view Usage : 3.75%

Mi code in python is:

proc = psutil.cpu_count()
for x in range(proc):
    suma = suma + psutil.cpu_percent(interval=1)

usecpu = suma / proc
print(usecpu)

Thanks for help

C - Compilation of OpenSSL: No reference to BIO-functions

I'm trying to compile a c-program with openssl-references.
Starting position:

LinuxMint 17.1 and the development package "libssl-dev" is installed.

//...
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
//...
void send_smtp_request(BIO *bio, const char *req){
       BIO_puts(bio, req);
       BIO_flush(bio);
       printf("%s", req);
}
//... more code

If I compile the code with:
gcc -o client bio-ssl-smtpcli2.c

I get the this error:
/tmp/ccCHrti2.o: In function 'send_smtp_request':
bio-ssl-smtpcli2.c:(.text+0x1f): undefined reference to 'BIO_puts'
bio-ssl-smtpcli2.c:(.text+0x3a): undefined reference to 'BIO_ctrl'

Someone has an idea how to fix this?

No module named distrib

I downloaded PyQRS which is a software for probabilistic and statstic, and i hit this error when i run python2.7 PyQRS27.pyc

Traceback (most recent call last):
   File "PyQRS.py", line 19, in <module>
ImportError: No module named distrib

I need to find which libs provides this module. Any idea?

Bash script does not sort by file type after IF

I need some help, guys. I have a bash code

#!/bin/bash
echo "Iveskite kataloga, kurio analize norite atlikti"
read katalogas
failai=$(find -x $katalogas)
for failas in $failai
do
if [[ -d "$failas" ]]
then 
   echo $failas " yra direktorija "
else
if [[ -x "$failas" ]]
then
echo $failas " yra vykdomasis failas "
else
if [[ -f "$failas" ]]
then
echo $failas " yra paprastasis failas "
fi
fi
fi
done

I want to make, that the final result would be sorted by file type. I do this: failai=$(find -x $katalogas) but It seems not working.

Is it possible that when using sudo command it should first source a file?

I need to run a bunch of scripts (with sudo) that use a single file.sh as a configuration file for all. Initially I've put the file.sh in /etc/profile.d and when I ran the scripts as root everything was ok (because when I connected to the machine it first sourced the file.sh and all vars in that file were available) but now, for security reasons, I need to run them with another user with sudo rights.

When running with sudo the "configuration file" in /etc/profile.d does not get sourced even if I'm root and do sudo - it's the same.

Using "sudo -E" is not an option, also this kind of solution "Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"" does not work for me as the vars in the file change a lot and it's easier to throw a file, with all the vars, in a location - like /etc/profile.d/ - instead to adding options to /etc/sudoers.

Later Edit (working):

Moved original sudo command to sudo.orig. Created a new sudo bash script

[root@NS1 bin]# cat sudo
#!/bin/bash
source /etc/profile.d/set_env_vmdeploy.sh
sh /usr/bin/sudo.orig "$@"

and gave it permissions

[root@NS1 bin]# chmod 4111 sudo
[root@NS1 bin]# ll sudo*
---s--x--x 1 root root     78 May  7 13:42 sudo
---s--x--x 1 root root 123832 Jul 31  2014 sudo.orig

Linux Kali - persistent storage

This is my first experience with Linux and I have a Kali Linux Live CD on my external HD. I followed this tutorial to set up an encrypted and persistent partition.

my partitions at the moment

/dev/sdb1 
/dev/sdb2  // file system
/dev/sdb3  // persistent storage ( Crypt-luks)

Now I wish to change my MAC address on each boot, so I added this to ect/netowrk/interfaces

ifconfig wlan0 down
macchanger -r wlan0
ifconfig wlan0 up

I can see the interfaces file has been created and updated in /lib/live/mount/persistence/sdb3/etc/network

The problem is that whenever I reboot my pc the commands I saved earlier are erased, and I basically find just an initial duplicate of interfaces

NullPointerException Playing Sound Clip on Linux

So, I made this 2D platformer game using Java AWT /Swing a few years back. When i tested it then at windows environment everything worked fine, but now that I am trying to test it in linux it always gets NullPointerException while trying to play sound. Here's my SoundEffects Class which is used throughout the game to play various sounds, it works perfectly in windows, but caused NullPointerException when i try to play the "jump" sound in linux.

package galib.platformer.sound;

import java.io.File;
import java.net.URL;
import java.util.HashMap;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JOptionPane;

import resources.ResourceLoader;

public class SoundEffects {

public HashMap<String, Clip> audioClips;

public void init() {

    audioClips = new HashMap<String, Clip>();

    try {


         Clip backgroundSound = AudioSystem.getClip();

         backgroundSound.open(AudioSystem.getAudioInputStream(new File("res/resources/sounds/background.wav")));

         audioClips.put("background_music", backgroundSound);


        Clip jumpSound = AudioSystem.getClip();

        jumpSound.open(AudioSystem.getAudioInputStream(new File("res/resources/sounds/jump.wav")));

        audioClips.put("jump_sound", jumpSound);



        Clip gemsCollectSound = AudioSystem.getClip();

        gemsCollectSound.open(AudioSystem.getAudioInputStream(new File("res/resources/sounds/gems.wav")));

        audioClips.put("gems_sound", gemsCollectSound);



        Clip destroySound = AudioSystem.getClip();

        destroySound.open(AudioSystem.getAudioInputStream(new File("res/resources/sounds/destroy.wav")));

        audioClips.put("destroy_sound", destroySound);


    } catch (Exception e) {
        // TODO Auto-generated catch block

        e.printStackTrace();
    }

}

}

I am not sure why is it causing NullPointerException when i run it on linux. Any guesses ? Thanks in advance. :)

linux kernel module not autoloading

I'm studing the linux kernel and start with hello world module at this point everything is fine but after compile

$ make

and install

$ insmod akmod.ko

the module it's not showing a "hello world" message on KERN_DEBUG

$ dmesg
nothing here
$

just show on rmmod

$ rmmod akmod
[4543.3423432] hello world
[5462.5323452] goodbye

The code is the same found here: http://ift.tt/1czSAi3

I just changed the KERN_ALERT for KERN_DEBUG

I'm using Debian 8.

I think that occurs because the module it´s not autoloading on insmod

When I run

$ make menuconfig

I can't find the option Automatic kernel module loading

Loadable module support  --->
  [*] Enable loadable module support
  [*]   Module unloading
  [ ]   Module versioning support (EXPERIMENTAL)
  [*]   Automatic kernel module loading **(My menu config don´t show this option)**

Any advice will be appreciated

Looping through an associative arrays with same key

I am currently trying to loop through an associative array. This array contains values with the same key. However, when i tried to loop through it, I only get one set of results. How can I loop through all the values containing the same key?

#!/bin/bash/
declare -A details=( [dog]="golden retriver" [cat]="bengal" [bird]="eagle" [dog]="bulldog" [cat]="sphynx" [bird]="parakeet" )

for k in "${!details[@]}"
        do
        echo $k --- ${details[$k]}
        done

Result

cat --- sphynx
dog --- bulldog
bird --- parakeet

Segfault in class destructor

Have a segfault in generated by gcc destructor of my Token class (code below and first screenshot). Almostly code works well but sometimes falls randomly

            Function: _ZNSsD2Ev
0xf77161af  <+0x003f>         lock xadd %ecx,-0x4(%eax)
0xf77161b4  <+0x0044>         mov    %ecx,%eax
0xf77161b6  <+0x0046>         test   %eax,%eax
0xf77161b8  <+0x0048>         jg     0xf7716191 <_ZNSsD2Ev+33>
0xf77161ba  <+0x004a>         sub    $0xc,%esp
0xf77161bd  <+0x004d>         push   %edx
0xf77161be  <+0x004e>         call   0xf76a9c70 <_ZdlPv@plt>
0xf77161c3  <+0x0053>         add    $0x10,%esp                //HERE
0xf77161c6  <+0x0056>         jmp    0xf7716191 <_ZNSsD2Ev+33>
0xf77161c8  <+0x0058>         nop
0xf77161c9  <+0x0059>         lea    0x0(%esi,%eiz,1),%esi
0xf77161d0  <+0x0060>         mov    -0x4(%eax),%ecx
0xf77161d3  <+0x0063>         lea    -0x1(%ecx),%esi
0xf77161d6  <+0x0066>         mov    %esi,-0x4(%eax)
0xf77161d9  <+0x0069>         mov    %ecx,%eax
0xf77161db  <+0x006b>         jmp    0xf77161b6 <_ZNSsD2Ev+70>
0xf77161dd                    xchg   %ax,%ax

Token class:

#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <cstring>
#include <iostream>
#include "common.h"
using namespace std;

#define ICUR (inc(cur_pos))

class Token //Qt Creator's debugger shows segfault HERE
{
    static const int EOL_REACHED = 0;
    static const int UNKNOWN_ESCAPE = 1;
    bool firstTime = true;
    string src, last, cur;
    uint cur_pos, last_pos; //I wanted to use string::iterator but it was a bug
                            //that was modifing all iterators after adding *cur_pos to result string after some chars

public:
    enum TokenType {
        String, Digit, Delim, Bool, Identifier, EOL, UNKNOWN
    };

    Token(string src) {
        this->src = src + " ";

        cur_pos = 0;

        last = cur = Next();
        last_pos = 0;
    }

    bool operator ==(string str) {
        return this->ToString() == str;
    }

    bool operator !=(string str) {
        return this->ToString() != str;
    }

    Token& operator>>(string& str) {
        str = this->Next();
        return *this;
    }

    string PushBack() {
        cur_pos = last_pos;
        cur = last;
        return cur;
    }

    string ToString() {
        return cur;
    }

    string Last() {
        return last;
    }

    string Next() {
        string res = "";
        try {
            last_pos = cur_pos;
            last = cur;
            res = cur = next();
        } catch (int ex) {
            switch(ex) {
            case EOL_REACHED:
                type = EOL;
                res = "";
                break;
            case UNKNOWN_ESCAPE:
                type = UNKNOWN;
                res = "";
                break;
            }
        }
        firstTime = false;
        return res;
    }

    string NextWhileNot(char ch, bool skip=false) {
        string res = "";
        res.reserve(src.length()+1);
        try {
            last_pos = cur_pos;
            last = cur;
            while(src[cur_pos] != ch  && cur_pos != src.length()) {
                res += src[cur_pos]; //sometimes falls with segfault HERE
                ICUR;
            }
            if(skip) ICUR;
            cur = res;
        } catch (int ex) {
            if(ex == EOL_REACHED) {
                type = EOL;
                res = "";
            }
        }
        return res;
    }

    Token &NextToken() {
        this->Next();
        return *this;
    }

    TokenType Type() {
        return type;
    }

private:
    TokenType type;

    string next() {
        //auto temp_pos = cur_pos;
        //const auto temp_last = last_pos;
        string result = "";
        bool isCyr = false;

        if(src[cur_pos] == '/' && src[cur_pos + 1] == '/') {
            ICUR;
            ICUR;
            while(src[cur_pos] != '\n') ICUR;
        }

        while(strchr(" \t\r\n", src[cur_pos])) ICUR;

        //cout << src[cur_pos] << endl;
        if(firstTime && src[cur_pos] == '.') {
            result += src[cur_pos];
            ICUR;
            while(isalpha(src[cur_pos]) || isdigit(src[cur_pos]) || src[cur_pos] == '-') {
                result += src[cur_pos];
                ICUR;
            }
        }
        else if(isalpha(src[cur_pos]) || src[cur_pos] == '_' || (isCyr = isCyrillicAlpha())) {
            result += src[cur_pos];
            if(isCyr)
            {
                ICUR;
                result += src[cur_pos];
            }
            ICUR;
            while(isalpha(src[cur_pos]) || isdigit(src[cur_pos])
                  || (strchr("_@$", src[cur_pos]) != NULL) || (isCyr = isCyrillicAlpha())) {
                if(src[cur_pos] == '\0') break;
                result.push_back(src[cur_pos]);
                if(isCyr)
                {
                    ICUR;
                    result.push_back(src[cur_pos]);
                }
                ICUR;
            }
            if(result == "true" || result == "false")
                type = Bool;
            else
                type = Identifier;
        }
        else if(isdigit(src[cur_pos])) {
            type = Digit;
            result += src[cur_pos];
            ICUR;

            bool hasDot = false;
            while ([&](){
                   if(src[cur_pos] == '.' && !hasDot) {
                        hasDot = true;
                        return true;
                   }
                   else if(isdigit(src[cur_pos])) return true;
                   return false;
                }()) {
                result += src[cur_pos];
                ICUR;
            }
        }
        else if(src[cur_pos] == '"') {
            type = String;
            ICUR;
            while(src[cur_pos] != '"') {
                if(src[cur_pos] == '\\') {
                    ICUR;
                    switch (src[cur_pos]) {
                        case '\\':
                            result += '\\';
                            break;
                        case 'a':
                            result += '\a';
                            break;
                        case 'b':
                            result += '\b';
                            break;
                        case 'v':
                            result += '\v';
                            break;
                        case 'n':
                            result += '\n';
                            break;
                        case 'r':
                            result += '\r';
                            break;
                        case 't':
                            result += '\t';
                            break;
                        case '0':
                            result += '\0';
                            break;
                        default:
                            throw UNKNOWN_ESCAPE;
                    }
                }
                else result += src[cur_pos];
                ICUR;
            }
            ICUR;
        }
        else if(src[cur_pos] == '-' && src[cur_pos + 1] == '>') {
            ICUR;
            ICUR;
            type = Delim;
            result = "->";
        }
        else if(strchr(".,+-=(){}[]|\!@#%^*&~`<>:", src[cur_pos])) {
            result = src[cur_pos];
            type = Delim;
            ICUR;
        }
        //cur_pos = temp_pos;
        //last_pos = temp_last;
        return result;
    }

    void inc(uint& iter) {
        ++iter;
        if(iter >= src.length()) throw EOL_REACHED;
    }

    bool isCyrillicAlpha()
    {
        //int i = (byte)src[cur_pos];
        //cout << i;
        if((byte)src[cur_pos] != 208 && (byte)src[cur_pos] != 209)
            return false;
        byte ch = (byte)src[cur_pos + 1];
        if(ch >= (byte)'а' && ch <= (byte)'п')
            return true;
        if(ch >= (byte)'р' && ch <= (byte)'я')
            return true;
        if(ch >= (byte)'А' && ch <= (byte)'Я')
            return true;
        return false;
    }
};

#undef ICUR

#endif // TOKEN_H

Valgrind shows something like thah, but it doesn't refers to Token class but refers to vector:

==14463== Invalid read of size 4
==14463==    at 0x8056127: std::vector<unsigned char, std::allocator<unsigned char> >::push_back(unsigned char const&) (stl_vector.h:915)
==14463==    by 0x804FCF6: pushAddr(unsigned int, std::vector<unsigned char, std::allocator<unsigned char> >&) (assembler.cpp:741)
==14463==    by 0x804F14F: Assembler::pushAddr(unsigned int, std::vector<unsigned char, std::allocator<unsigned char> >&) (assembler.cpp:596)
==14463==    by 0x804D669: Assembler::compileFunc(Function&) (assembler.cpp:325)
==14463==    by 0x804CAD6: Assembler::Compile() (assembler.cpp:224)
==14463==    by 0x8049C82: main (main.cpp:21)
==14463==  Address 0x4391134 is 92 bytes inside a block of size 928 free'd
==14463==    at 0x402D7B8: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14463==    by 0x8060D02: __gnu_cxx::new_allocator<Function>::deallocate(Function*, unsigned int) (new_allocator.h:110)
==14463==    by 0x805E603: std::allocator_traits<std::allocator<Function> >::deallocate(std::allocator<Function>&, Function*, unsigned int) (alloc_traits.h:383)
==14463==    by 0x805B075: std::_Vector_base<Function, std::allocator<Function> >::_M_deallocate(Function*, unsigned int) (stl_vector.h:178)
==14463==    by 0x805834B: void std::vector<Function, std::allocator<Function> >::_M_emplace_back_aux<Function const&>(Function const&) (vector.tcc:438)
==14463==    by 0x8055DD5: std::vector<Function, std::allocator<Function> >::push_back(Function const&) (stl_vector.h:923)
==14463==    by 0x804D639: Assembler::compileFunc(Function&) (assembler.cpp:322)
==14463==    by 0x804CAD6: Assembler::Compile() (assembler.cpp:224)
==14463==    by 0x8049C82: main (main.cpp:21)
==14463== 
==14463== Invalid read of size 4
==14463==    at 0x805612D: std::vector<unsigned char, std::allocator<unsigned char> >::push_back(unsigned char const&) (stl_vector.h:915)
==14463==    by 0x804FCF6: pushAddr(unsigned int, std::vector<unsigned char, std::allocator<unsigned char> >&) (assembler.cpp:741)
==14463==    by 0x804F14F: Assembler::pushAddr(unsigned int, std::vector<unsigned char, std::allocator<unsigned char> >&) (assembler.cpp:596)
==14463==    by 0x804D669: Assembler::compileFunc(Function&) (assembler.cpp:325)
==14463==    by 0x804CAD6: Assembler::Compile() (assembler.cpp:224)
==14463==    by 0x8049C82: main (main.cpp:21)
==14463==  Address 0x4391138 is 96 bytes inside a block of size 928 free'd
==14463==    at 0x402D7B8: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14463==    by 0x8060D02: __gnu_cxx::new_allocator<Function>::deallocate(Function*, unsigned int) (new_allocator.h:110)
==14463==    by 0x805E603: std::allocator_traits<std::allocator<Function> >::deallocate(std::allocator<Function>&, Function*, unsigned int) (alloc_traits.h:383)
==14463==    by 0x805B075: std::_Vector_base<Function, std::allocator<Function> >::_M_deallocate(Function*, unsigned int) (stl_vector.h:178)
==14463==    by 0x805834B: void std::vector<Function, std::allocator<Function> >::_M_emplace_back_aux<Function const&>(Function const&) (vector.tcc:438)
==14463==    by 0x8055DD5: std::vector<Function, std::allocator<Function> >::push_back(Function const&) (stl_vector.h:923)
==14463==    by 0x804D639: Assembler::compileFunc(Function&) (assembler.cpp:322)
==14463==    by 0x804CAD6: Assembler::Compile() (assembler.cpp:224)
==14463==    by 0x8049C82: main (main.cpp:21)

Linux shell file. mkdir and pushd commands not doing what I'd like

I'm trying to create a directory if it does not exist, and the further down the line, create a log file in that directory. It would be in the current users home directory
In pseudocode:

If directory "/home/LOGS" does not exist
make directory "/home/LOGS"

Then whenever a log file is created, it will save in that directory, not the directory that the program is being run from.
This is what I have so far, and it's just not working...

pushd -n  $"../LOGS" >/dev/null 2>&1 

#Create the logs folder
if [ ! -d $"home/LOGS" ]; then
 mkdir -p $"home/LOGS"
fi 

If it helps, my files are being saved like so:

     function savefile {
# Save to file
  if [ -e $username.log ]; then
    echo "Username already exists, returning you to the menu."
    sleep 2
    clear
      menu
  else
    echo $fullname >> $username.log
    echo $password >> $username.log
      curdate=$(date +'%d/%m/%Y %H:%M:%S')
    echo $curdate >> $username.log
  echo "Creating your account"
    sleep 2
    clear
  echo "Account created"
  echo
    afterBasic
  fi 
}

Any help would be greatly appreciated.

how to get the coordinate of cursor when setting PS1 variable for command line prompt?

I'm using Mac. I want to set PS1 variable to get current time at the end of line in command line prompt. Like this: exmaple 1 or this: example 2

But, unfortunately, I can't get what I want through following configuration:

CYAN="\[$(tput setaf 6)\]"
GREEN="\[$(tput setaf 2)\]" 
BLUE="\[$(tput setaf 4)\]"
YELLOW="\[$(tput setaf 3)\]" 
export PS1="$GREEN\u$BLUE@$CYAN\h $YELLOW\w\[$(tput cuf $(($(tput cols)-33)))\]$CYAN\[$(date +%H:%M)\]\n\\$ "

It seems that I need to get the current position of cursor and do some computations based on the coordinate of the position, but I don't know how to get it. Is anyone can help?

how to compile and run java in linux with 3rd party jar and my own jar

I export my own project into a jar, and this project needs two 3rd-party jars, an extra TestMyJar.class is used to test my project, how to do this? I have tried several methods but no luck. To be more specific, this is my jar: a class that only delivers hello world message a url. I export this class code into a helloworld.jar

package com.wow.flow.http.dq;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;

public class HttpConnection {

    @SuppressWarnings("deprecation")
    public void client() throws Exception {

        String url = "www.someurl.com"; // sorry if this your registered url, just borrow it as an example
        if (url == null) {
            throw new Exception();
        }

        HttpClient client = new HttpClient();

        PostMethod postMethod = new UTF8PostMethod(url);
        try {
            postMethod.setRequestBody("Hello world");
            int statusCode = client.executeMethod(postMethod);

            if (statusCode == HttpStatus.SC_OK) {

                InputStream responseBody = postMethod.getResponseBodyAsStream();
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(responseBody, "utf-8"));
                String line = reader.readLine();
                while (line != null) {
                    System.out.println(new String(line.getBytes()));
                    line = reader.readLine();
                }
            }

        } catch (HttpException e) {
            // TODO: handle exception
        } catch (IOException e) {
            // TODO: handle exception
        } finally {
            postMethod.releaseConnection();
        }
    }

    // Inner class for UTF-8 support
    public static class UTF8PostMethod extends PostMethod {
        public UTF8PostMethod(String url) {
            super(url);
        }

        @Override
        public String getRequestCharSet() {
            // return super.getRequestCharSet();
            return "UTF-8";
        }
    }

}

It requires dom4j and httpclient. This is my TestMyJar.class:

package httptest

public class TestMyJar {
    public static void main(String[] args) {
        HttpConnection connection= new HttpConnection();
    }
}

Now I have three jar: helloworld.jar, commons-httpclient-3.1.jar, dom4j-1.6.1.jar, and a class: TestMyJar.java. How can I compile and run TestMyJar.java? I have tried with javac and java, but it is all something cannot be found.

Thanks!

Grep\Sed between two tags with multiline

I have many files with whom I need to get information.

Example of my files:

first file content:

"test This info i need grep</singleline>"

and

second file content (with two lines):

"test This info=
 i need grep too</singleline>"

in results i need grep this text: from first file - "This info i need grep" and from second file - "This info= i need grep too"

in first file i use:

grep -o 'test .*</singleline>' * | sed -e 's/test \(.*\)<\/singleline>/\1/'

and successfully get "This info i need grep" but I can not get the information from the second file by using the same command. Please help rewrite the command or write what the other. Very big thanks!

High performance packet processing under Linux

I would like to analyze packets (in practice doing deep packet inspection) on a specialized Linux machine. The machine has up to 10x 1Gb Ethernet NICs. How can I get the packets with good performance to an userspace program ?

How to use macro define for x86 and 8664 linux in c

I want to compile part of my code only on x86 and 8664 linux, but not s390 linux or others. How to use the macro define in C to achieve it? I know linux is to determine linux OS, and 386, 486 and 586 to determine CPU architecture. Is there an easy macro define to determine x86 linux and 8664 linux? Thanks

Error while trying to run Spark

I am new to spark. I have downloaded the spark version 1.3.1 prebuilt for hadoop version 2.6 . I extracted and navigated to the folder and typed in the below command : ./bin/spark-shell for which i get an error which says spark-shell command not found. I did the same on windows using git bash for which I get an error saying

spark-submit : line 26 tput command not found

is there something else I need to do before trying to run spark?

Primefaces push in linux

I have deployed 2 web applications which have the push (notification) functions. Firstly, I deploy the first app (PUSH_SERVER) and publish web service. When the web method is called, the notification will be push to the second application. My configuration for the second app is as below:

<context-param>
    <param-name>primefaces.PUSH_SERVER_URL</param-name>
    <param-value>myURL</param-value>
</context-param>

The strange thing is: The push runs really well in Windows. But when I deploy them in Linux, in the same server. The first app is still able to get the notification. However, when I open the second app, I get this error (from FireBug):

Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
Websocket closed, wasClean: false
Websocket failed. Downgrading to Comet and resending

I'm really confusing about this error. Would you give me some suggests?

Which database type is better for around 10 million data, windows or linux

i have around 10 millions of record for my website.i will create a search on my website for my recoreds. which database is comparetively faster linux or windows

Changing /etc/hosts with sed command

I'm trying to change /etc/hosts file with sed command , I use sudo to execute the following command

 sudo sed 's/127.0.0.1 localhost/127.0.0.1 localhost mydomain.com/g' /etc/hosts |sudo cat > /etc/hosts

but this is the error that I get

-bash: /etc/hosts: Permission denied

how many maximum concurrent users can a tomcat instance, jboss instance and weblogic instance handle?

I am willing to launch a web application. It was completely on the structs only and no springs are used in it. We are willing to launch in either tomcat or jboss or weblogic application servers.

So, I may get many users' hits to the application. My hardware is 32GB/8cores and the OS is RHEL6.3. So, I would like to know how many maximum concurrent users can a tomcat instance handle. Similar the way, I would like to know about the maximum concurrent users that jboss-as and weblogic also handle.

Thanks in advance

daemon: closed stderr and accept(2)

I wrote a TCP daemon, that accepts clients connections on given port and after that it executes a command using execv(3). In every tutorial on writting daemons it is mentioned to close stdin, stdout, stderr to sucessfully daemonize the process.

However I found out that accept(2) reuses file descriptor numbers of already closed stdout/stderr so after calling fork(2) and execv(3), child process writes output to socket simply because stdout/stderr maps to file descriptor now associated with client socket.

Any ideas how can I avoid this without resorting to shell output redirection?

Resetting Default Grub Boot menu

1.First I install windows 7. 2.next i install ubuntu linux 3.I use both os using boot menu option 4.i reinstall windows 7 some slow reason 5.the boot menu is gone 6.how do i retrieve the boot menu is any tool there in windows? please explain me how to retrive the bootloader menu.

enter image description here

How to put arguments in a function at run time?

So I am using execlp in my c++ program. execlp is of the form " int execlp(const char *file, const char *arg0,...,const char *argn)" meaning that it can take arbitrary amount of arguments. I just want to know that is there a way I can put arguments inside this function at run time? Since the arguments are provided by the user, there is no way for me to know the exact number of arguments. Of course I can pick a ridiculously large number from the start but that won't be very efficient.I need a more efficient way that would allow me to put arguments at run time.

setup python+uWSGI: unable to load app

i'm following this Quickstart to set up an easy python uWSGI application.
My applicaiton is like:

def application(env, start_response):  
start_response('200 OK', [('Content-Type','text/html')])  
return ["Hello World"]

And i'm running uwsgi like:

uwsgi --http :9090 --wsgi-file test.py 

however, from the uwsgi output, it seems not successfully loaded the app:

* Starting uWSGI 2.0.10 (64bit) on [Sat May 9 10:43:42 2015]
compiled with version: 4.6.3 on 09 May 2015 10:02:20
os: Linux-3.13.0-49-generic #81~precise1-Ubuntu SMP Wed Mar 25 16:32:15 UTC 2015 nodename: XXX machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/YYY/proj/uwsgi-tutorial/mysite
detected binary path: /home/YYY/proj/uwsgi-tutorial/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
WARNING: you are running uWSGI without its master process manager
your processes number limit is 13261
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :9090 fd 4
spawned uWSGI http 1 (pid: 7713)
uwsgi socket 0 bound to TCP address 127.0.0.1:47552 (port auto-assigned) fd 3
Python version: 2.7.3 (default, Dec 18 2014, 19:25:50) [GCC 4.6.3]
Python threads support is disabled. You can enable it with --enable-threads
Python main interpreter initialized at 0xed4cc0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
Operational MODE: single process
failed to open python file tests.py
unable to load app 0 (mountpoint='') (callable not found or import error)
no app loaded. going in full dynamic mode
uWSGI is running in multiple interpreter mode *
spawned uWSGI worker 1 (and the only) (pid: 7712, cores: 1)

and when i try to access the page from browser, it failed with message "This webpage is not available"

Any idea why uWSGI failed to load the test.py application?
And i'm running all this on ubuntu-12.04 in a fresh Azure VM

Linux routing loop

I have to set up a DMZ lab, but I am having issues with the basic network configuration. This is the main configuration:

FW1 - FLAME

Interfaces

eth0 - 192.168.1.3 255.255.255.0 gw 192.168.1.1 (its a virtual environment, this interface is bridged)

eth1 - 192.168.136.1 255.255.255.0

Routing table

0.0.0.0 ----------- 192.168.1.1 ------- eth0

192.168.136.0 --- 0.0.0.0 ------------ eth1

FW2 - ARROW

Interfaces

eth0 - 192.168.136.200 255.255.255.0 gw 192.168.136.1

eth1 - 192.168.30.10 255.255.255.0

Routing table

0.0.0.0 ----------- 192.168.136.1 ------- eth0

192.168.30.0 ---- 0.0.0.0 ---------------- eth1

I also have set to 1 ipv4 forwarding, and set the following IPtables rule in FLAME:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

I tried most of this configuration other times and it worked, but I can't see what am I doing wrong here.

When I try to ping from ARROW to Internet, I can't reach it, but I can ping the eth1 interface on FLAME (it's gateway). Trying to do a traceroute results in a bunch of asterisks, which I interpret as a routing loop.

From FLAME I can reach Internet normally.

This must be a misconfiguration on FLAME, but I cant figure it out. Any ideas?

How to get system, user info with pure qml linux

recently I am preparing pure qml plasmoid for my new panel appereancce in KDE Plasma 4 and i have to use at most QT 4.7 library and Qt.Quick 1.1 for that so is it possible to pick up current user's fullname ? Is there any plasma API related to that like PlasmaCore or KSM etc. Or any PlasmaCore datasource engine like

#import org.kde.PlasmaCore 0.1 PlasmaCore
{
  Item{
      PlasmaCore.DataSource{
          engine  : "SystemInformation"
          connection : "get_user_fullname"
      }
  }
}

this. Or should I build a service like this. What is your suggestions, and thoughts ? Thanks in advence.

SED in remote SUDO ssh script

I am trying to disable RHN check when running yum on 1000 servers. It is done by:

Editing this file /etc/yum/pluginconf.d/rhnplugin.conf

[main]
enabled = 0 

I wrote a script to do this remotely. We are using individual accounts and I need to execute this command using SUDO:

for HOST in $(cat serverlist ) ; do echo $HOST; ssh -o ConnectTimeout=5 -oStrictHostKeyChecking=no $HOST -t 'sudo cp /etc/yum/pluginconf.d/rhnplugin.conf /etc/yum/pluginconf.d/rhnplugin.$(date +%F) ; sudo sed -i -e "s/1/0/g" /etc/yum/pluginconf.d/rhnplugin.conf ' ; done

I know it is a long line but why does it not work?

All individual commands work on their own

sudo cp /etc/yum/pluginconf.d/rhnplugin.conf /etc/yum/pluginconf.d/rhnplugin.$(date +%F)

sudo sed -i -e "s/1/0/g" /etc/yum/pluginconf.d/rhnplugin.conf

have tried escaping the special chars:

sudo sed -i -e "s\/1\/0\/g" /etc/yum/pluginconf.d/rhnplugin.conf

But I get an error all the time:

sed: -e expression #1, char 1: unknown command: `?'

Thanks for your help.

Reinjecting modified packets in netfilter module

I have used netfiler_queue to create a NFQUEUE module for iptables that handles all outgoing UDP packets.

I want to modify all UDP packets that match a certain pattern, and reinject them into the network.

Here is some example code:

...

static int Callback( nfq_q_handle *myQueue, struct nfgenmsg *msg, nfq_data *pkt, void *cbData) {
  uint32_t id = 0;
  nfqnl_msg_packet_hdr *header;

  if ((header = nfq_get_msg_packet_hdr(pkt))) {
    id = ntohl(header->packet_id);
  }

  // Get the packet payload
  unsigned char *pktData;
  int len = nfq_get_payload(pkt, &pktData);

  // The following is an example. 
  // In reality, it involves more parsing of the packet payload.
  if (len && pktData[40] == ') {
    // Modify byte 40
    pktData[40] = 'Y';
  }

  // Pass through the (modified) packet.
  return nfq_set_verdict(myQueue, id, NF_ACCEPT, 0, NULL);
}

...

int main(){

  ...

  struct nfq_handle nfqHandle;
  nfq_create_queue(nfqHandle,  0, &Callback, NULL)

  ...

  return 0;
}

I am not allowed to share the full source code, so this example is made specifically for this question, I hope this example code is not too dumbed down.

The modified packet does not get reinjected into the stream. How would I inject the modified version of the packet?

Start tomcat in intellij community edition

Hi am trying to start tomcat in intellij 14 community edition. I have configured it as an external tools. in windows I could do it with by pointing the program to catalina.bat and in parameters i could type jpda start. But in linux machine i am pointing the program to Catalina.sh and in parameters i am typing jpda start. But when i run it it is showing permission denied. Below is the exact error. how can i fix it?

Error:

Error running Tomcat: Cannot run program "/home/creative/work/apache-tomcat-8.0.12/bin/catalina.sh" (in directory "/home/creative/work/apache-tomcat-8.0.12/bin"): error=13, Permission denied

Detect closed connection on non blocking socket

I'm really sorry if my question is a duplicate, but I didn't find useful infos in the site.

I'm using non blocking sockets and a select(). How can I detect if a client closed the connection on non-blocking socket? I saw that a read() returns -1 with errno = EWOULDBLOCK when no datas are available to be read and also when a connection is closed.

How can I discriminate above cases?

Thanks!

ttys on separate monitors

How to use both monitors of a dual-head system in console mode? I.e., how to make, e.g., /dev/tty1 appear on the first monitor and /dev/tty2 on the second?

(As far as I have found out, people have asked about this on the Internet before, but nobody seems to have got a real answer; instead, they have usually been told to open two terminal windows under X on separate screens. I know how to do this, and this is expressly not what I am asking. What I want to know is how to have real text mode ttys on separate monitors.)

Malloc: How to forcefully free the memory indicated by mallinfo fordblks

My application frees up a huge chunk of memory on receiving a particular event. Here is the mallinfo stats before the event. 2015-05-08 19:39:28,453 INFO sas2 - Total non-mmapped bytes (arena): 181747712 2015-05-08 19:39:28,453 INFO sas2 - # of free chunks (ordblks): 14340 2015-05-08 19:39:28,453 INFO sas2 - # of free fastbin blocks (smblks): 17 2015-05-08 19:39:28,453 INFO sas2 - # of mapped regions (hblks): 36 2015-05-08 19:39:28,453 INFO sas2 - Bytes in mapped regions (hblkhd): 139460608 2015-05-08 19:39:28,453 INFO sas2 - Max. total allocated space (usmblks): 0 2015-05-08 19:39:28,453 INFO sas2 - Free bytes held in fastbins (fsmblks): 912 2015-05-08 19:39:28,453 INFO sas2 - Total allocated space (uordblks): 175712192 2015-05-08 19:39:28,453 INFO sas2 - Total free space (fordblks): 6035520 2015-05-08 19:39:28,453 INFO sas2 - Topmost releasable block (keepcost): 60112

The stats after processing the event are 2015-05-08 19:40:44,696 INFO sas2 - Total non-mmapped bytes (arena): 181747712 2015-05-08 19:40:44,696 INFO sas2 - # of free chunks (ordblks): 797 2015-05-08 19:40:44,696 INFO sas2 - # of free fastbin blocks (smblks): 0 2015-05-08 19:40:44,696 INFO sas2 - # of mapped regions (hblks): 38 2015-05-08 19:40:44,696 INFO sas2 - Bytes in mapped regions (hblkhd): 153735168 2015-05-08 19:40:44,696 INFO sas2 - Max. total allocated space (usmblks): 0 2015-05-08 19:40:44,696 INFO sas2 - Free bytes held in fastbins (fsmblks): 0 2015-05-08 19:40:44,696 INFO sas2 - Total allocated space (uordblks): 1056528 2015-05-08 19:40:44,696 INFO sas2 - Total free space (fordblks): 180691184 2015-05-08 19:40:44,696 INFO sas2 - Topmost releasable block (keepcost): 238368 As you can see, there is almost 180MB of free memory indicated by fordblks. Although the application frees up the memory, malloc doesn't seem to give it back to kernel. Since my system is already memory constrained, I cannot afford to lose such a huge chunk of memory. Is there a way I can forcefully free the bytes indicated by fordblks?

I tried malloc_trim and it didn't help. As you can see, it just frees the "keepcost" bytes.

Counting only lines with words in them

How can I numerically count only lines that have words in them? In the example below, I have four lines with words in them:

100314:Status name one: 15
24 1 7 5 43 13 24 64 10 47 31 100 22 20 38 63 49 24 18 82 66 22 21 77 52 8 6 11 50 20 5 1 0 
101245:Status name two: 14
2 10 2 2 25 53 3 31 30 1 21 41 9 14 18 40 6 10 18 72 20 16 33 29 19 18 12 60 48 12 8 50 43 13
103765:Yet another name here: 29
45 29 29 475 63 69 47 94 65 65 69 55 53 905 117 57 42 92 90 59 91 52 79 101 192 87 144 74 115 82 78 109 12 96 64 78 111 106 84 19 0 7 
102983:Blah blah yada yada: 82
41 37 40 60 82 72 17 41 17 19 43 3

I've tried using different pipe combinations of wc -l and grep/uniq. I also tried counting only the odd lines (which works in the MWE above), but I'm looking for something more general-purpose for a large unstructured dataset.

gdb: examine stack and little endian clarification

I am studying about the memory layout of a program. I am using gdb to examine the stack in a little endian (intel x86_64) Linux (32 bit) machine. However, I am not able to understand the concept of big-endian and little-endian w.r.t this processor and gdb.

My sample program is:

1   #include<stdio.h>
2   
3   int main(int argc, char **argv) {
4       int a = 5;
5       char b[] = "ABCDEFGH";
6   
7       return 0;
8   }

                       [Code - 1]

The following sequence of instructions were executed in gdb.

(gdb) b 7
Breakpoint 1 at 0x8048434: file args.c, line 7.
(gdb) r
Breakpoint 1, main (argc=1, argv=0xbffff4f4) at args.c:7
7       return 0;

(gdb) x/20xw $esp
0xbffff410: 0x0011e0c0  0x08049ff4  0xbffff448  0xbffff4f4
0xbffff420: 0x00284324  0x00283ff4  0x08048470  0x00000005
0xbffff430: 0x4115d4a5  0x45444342  0x00484746  0x6a078d00
0xbffff440: 0x08048470  0x00000000  0xbffff4c8  0x00144bd6
0xbffff450: 0x00000002  0xbffff4f4  0xbffff500  0xb7fff858


                            [Code - 2]

Initially, I was confused whether the memory address 0xbffff430 in the stack above contains the value 0x41 or 0xa5. So I examined the stack starting from the address 0xbffff433.

(gdb) x/8xw 0xbffff433
0xbffff433: 0x44434241  0x48474645  0x078d0000  0x0484706a
0xbffff443: 0x00000008  0xfff4c800  0x144bd6bf  0x00000200

                             [code - 3]

As evident from the output above, the address 0xbffff433 contains the value 0x41. Thus, the address 0xbffff430 contains the value 0xa5. Thus we can conclude that memory addresses in gcc are displayed in the following order:-

0xbffff433: [0xbffff436][0xbffff435][0xbffff434][0xbffff433]  [0xbffff43a] [0xbffff439][0xbffff438][0xbffff437]
                D           C          B           A             H              G              F          E

However, since intel x86_64 is little-endian, from what I understand the order in which the character array is stored (MSB at smallest address) should be as follows:-

0xbffff433: [0xbffff436][0xbffff435][0xbffff434][0xbffff433]  [0xbffff43a][0xbffff439][0xbffff438][0xbffff437]
                 A           B         C           D             E           F           G           H

Q (a): Could some please explain where am I getting wrong?

Q (b): Furthermore, from [code 2] above we can see that the value for variable a is stored at the address 0xbffff42c. The value for variable a is: 0x00000005. Here also LSB is stored at the smallest memory address.

Q (c): However, the problem from Q (a) and (b) doesn't manifest when addresses are stored. For example, from code - 4 below we can check that at the address 0xbffff448 EBP (0xbffff4c8) is stored

(gdb) x/4xw $ebp
0xbffff448: 0xbffff4c8  0x00144bd6  0x00000002  0xbffff4f4

It is clearly visible that the address is stored in the following order:-

0xbffff448: [0xbffff44b][0xbffff44a][0xbffff449][0xbffff448]
                0xbf        0xff        0xf4        0xc8

Note: 1) I tried the above code on a VM of ubuntu-10.04-desktop-i386. I confirmed the endianness of my machine using the following code:

#include <stdio.h>
int main() 
{
   unsigned int i = 1;
   char *c = (char*)&i;
   if (*c)    
       printf("Little endian");
   else
       printf("Big endian");
   getchar();
   return 0;
}

2) I checked the following thread too Is GDB interpreting the memory address correctly? but I am still not able to understand the concept.

Thanks.

pygtk scale image to width and height

is it possible to read an image using Python and pyGTK and change the displayed size (i.e width=xxx height=xxx pixels)?

Sorry, about this question. It probably is very simple, but I haven't found an answer yet.

Linux Clean Installation ERROR IN BOOT: "Reboot and select proper boot device or insert boot media in selected boot device"

After installing a clean copy of linux elementary os. It shows me "Reboot and select proper boot device or insert boot media in selected boot device". I'm using a laptop and previously I was running windows 8.1. When i try to install windows again it boots perfectly and everything is great. When i go to the bios after linux is installed it doesn't recognize the hdd it just shows boot from dvd. My partitions look like this: [img] http://ift.tt/1Ins6gL

Is there a problem with the partitions ?

Android linux deploy (localhost LAMP server configuration)

Hello my fellow humans!

I have two rooted android phones, each running a chroot environment using the "Linux Deploy" app (HTC desire 510 running Kali Linux and vodafone smart 4 mini running Ubuntu). On each device, I have installed LAMP using:

aptitude install php5 php5-gd php5-cgi php5-mysql mysql-server mysql-client php5-curl lynx php-pear ca-certificates xml-core apache2 libapache2-mod-php5

When I start apache2 service, the server says that it has started using ServerName 127.0.0.1. However, when I do nmap -p 80 127.0.0.1, the port is closed. Netstat shows no process using port 80 and my fingers are violently bleeding from playing around with iptables all day. Changing the listening port in apache configuration doesnt seem to work either. Perhaps it is something to do with iptables in the anroid kernal? I am simply trying to get this webserver available on port 80 of the phones LAN address. I am totally stumped, any help at all will be greatly appreciated!

Linux Deploy: http://ift.tt/1n0Jmc6

apache2.config (ubuntu environment)

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://ift.tt/1fRRexk;);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
LockFile ${APACHE_LOCK_DIR}/accept.lock

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxClients: maximum number of simultaneous client connections
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
# It is also possible to omit any default MIME type and let the
# client's browser guess an appropriate action instead. Typically the
# browser will decide based on the file's extension then. In cases
# where no good assumption can be made, letting the default MIME type
# unset is suggested  instead of forcing the browser to accept
# incorrect  metadata.
#
DefaultType None


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/
root@localhost:/etc/apache2#

netstat results (ubuntu environment)

root@localhost:/etc/apache2# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0    312 192.168.1.8:ssh         192.168.1.10:58501      ESTABLISHED
tcp6       1      0 192.168.1.8%13923:50042 syd01s18-in-f1.1e:https CLOSE_WAIT
tcp6       1      0 192.168.1.8%13924:45698 syd01s19-in-f9.1e:https CLOSE_WAIT
tcp6       0      0 192.168.1.8%13926:53997 tg-in-f188.1e100.n:5228 ESTABLISHED
tcp6       1      0 192.168.1.8%13928:48576 183.61.112.29:http      CLOSE_WAIT
tcp6       1      0 192.168.1.8%13929:55681 syd01s18-in-f6.1e1:http CLOSE_WAIT
tcp6      24      0 192.168.1.8%13931:36897 ec2-54-241-32-22.:https CLOSE_WAIT
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         STREAM                   776      /dev/socket/rild-mtk-modem
unix  2      [ ]         STREAM                   1545     /dev/socket/adbd
unix  2      [ ]         STREAM                   205      @@king_dserver:1
unix  2      [ ]         STREAM                   1483     @@king_dserver:0
unix  2      [ ]         STREAM                   211      @@king_dserver:2
unix  2      [ ]         DGRAM                    344      @/dev/socket/palinjectsock
unix  2      [ ]         DGRAM                    342      @/dev/socket/palhal
unix  2      [ ]         DGRAM                    3701     /dev/socket/wpa_wlan0
unix  2      [ ]         DGRAM                    343      @/dev/socket/paltimersock
unix  2      [ ]         DGRAM                    341      @palbt_bt30hs
unix  4      [ ]         DGRAM                    4381     /data/misc/wpa_supplicant/wlan0
unix  4      [ ]         DGRAM                    4396     /data/misc/wpa_supplicant/p2p0
unix  2      [ ]         DGRAM                    4386     /data/misc/wifi/sockets/wpa_ctrl_816-2
unix  2      [ ]         DGRAM                    4387     /data/misc/wifi/sockets/wpa_ctrl_816-3
unix  2      [ ]         DGRAM                    4416     /data/misc/wifi/sockets/wpa_ctrl_816-4
unix  2      [ ]         DGRAM                    4417     /data/misc/wifi/sockets/wpa_ctrl_816-5
unix  2      [ ]         STREAM                   168      /dev/socket/atci-serv-fw
unix  2      [ ]         STREAM                   170      /dev/socket/atci-service
unix  2      [ ]         DGRAM                    1464     /dev/socket/soc_vt_svc
unix  2      [ ]         DGRAM                    1466     /dev/socket/soc_vt_stk
unix  2      [ ]         DGRAM                    1468     /dev/socket/soc_vt_tcv
unix  3      [ ]         DGRAM                    348      /data/agps_supl/soc_soc
unix  2      [ ]         DGRAM                    350      /data/agps_supl/soc_supl
unix  2      [ ]         DGRAM                    355      /data/agps_supl/soc_tls
unix  2      [ ]         DGRAM                    351      /data/agps_supl/mnl2supl
unix  2      [ ]         DGRAM                    1966     /data/agps_supl/soc_rrlp
unix  2      [ ]         DGRAM                    353      /data/agps_supl/agps_mgr
unix  2      [ ]         DGRAM                    356      /data/agps_supl/soc_mmi
unix  2      [ ]         DGRAM                    357      /data/agps_supl/soc_gps
unix  2      [ ]         DGRAM                    3537     @bt.app.gap.twin
unix  2      [ ]         DGRAM                    3536     @bt.app.gap
unix  2      [ ]         DGRAM                    1529     /dev/socket/bt.a2dp.stream
unix  3      [ ]         DGRAM                    1531     /dev/socket/bt.int.adp
unix  2      [ ]         STREAM                   1533     /dev/socket/backuprestore
unix  3      [ ]         STREAM     CONNECTED     61257
unix  3      [ ]         STREAM     CONNECTED     61256
unix  3      [ ]         STREAM     CONNECTED     61079
unix  3      [ ]         STREAM     CONNECTED     61078
unix  3      [ ]         STREAM     CONNECTED     61069
unix  3      [ ]         STREAM     CONNECTED     61068
unix  2      [ ]         DGRAM                    59406
unix  3      [ ]         SEQPACKET  CONNECTED     44431
unix  3      [ ]         SEQPACKET  CONNECTED     44430
unix  3      [ ]         STREAM     CONNECTED     45386
unix  3      [ ]         STREAM     CONNECTED     45385
unix  3      [ ]         STREAM     CONNECTED     42809
unix  3      [ ]         STREAM     CONNECTED     42808
unix  3      [ ]         SEQPACKET  CONNECTED     23826
unix  3      [ ]         SEQPACKET  CONNECTED     23825
unix  3      [ ]         SEQPACKET  CONNECTED     22620
unix  3      [ ]         SEQPACKET  CONNECTED     22619
unix  3      [ ]         SEQPACKET  CONNECTED     18542
unix  3      [ ]         SEQPACKET  CONNECTED     18541
unix  2      [ ]         STREAM     CONNECTED     10052    /data/data/com.kingroot.kinguser/cache/.socketgTt170
unix  3      [ ]         SEQPACKET  CONNECTED     6932
unix  3      [ ]         SEQPACKET  CONNECTED     6931
unix  3      [ ]         SEQPACKET  CONNECTED     7543
unix  3      [ ]         SEQPACKET  CONNECTED     7542
unix  3      [ ]         SEQPACKET  CONNECTED     6923
unix  3      [ ]         SEQPACKET  CONNECTED     6922
unix  3      [ ]         SEQPACKET  CONNECTED     6921
unix  3      [ ]         SEQPACKET  CONNECTED     6920
unix  3      [ ]         SEQPACKET  CONNECTED     7389
unix  3      [ ]         SEQPACKET  CONNECTED     7388
unix  3      [ ]         STREAM     CONNECTED     4864     /dev/socket/rild
unix  3      [ ]         STREAM     CONNECTED     5130
unix  3      [ ]         SEQPACKET  CONNECTED     4849
unix  3      [ ]         SEQPACKET  CONNECTED     4848
unix  3      [ ]         SEQPACKET  CONNECTED     4050
unix  3      [ ]         SEQPACKET  CONNECTED     4049
unix  3      [ ]         SEQPACKET  CONNECTED     4726
unix  3      [ ]         SEQPACKET  CONNECTED     4725
unix  2      [ ]         STREAM                   3846
unix  3      [ ]         STREAM     CONNECTED     4524     @com.kingroot.master.ap
unix  3      [ ]         STREAM     CONNECTED     4525
unix  2      [ ]         STREAM     CONNECTED     4522
unix  3      [ ]         STREAM     CONNECTED     4419
unix  3      [ ]         STREAM     CONNECTED     4418
unix  3      [ ]         SEQPACKET  CONNECTED     3726
unix  3      [ ]         SEQPACKET  CONNECTED     3725
unix  3      [ ]         STREAM     CONNECTED     3717
unix  3      [ ]         STREAM     CONNECTED     3716
unix  3      [ ]         STREAM     CONNECTED     4292     /dev/socket/zygote
unix  3      [ ]         STREAM     CONNECTED     3643
unix  3      [ ]         SEQPACKET  CONNECTED     3642
unix  3      [ ]         SEQPACKET  CONNECTED     3641
unix  3      [ ]         SEQPACKET  CONNECTED     3639
unix  3      [ ]         SEQPACKET  CONNECTED     3638
unix  3      [ ]         SEQPACKET  CONNECTED     3633
unix  3      [ ]         SEQPACKET  CONNECTED     3632
unix  3      [ ]         STREAM     CONNECTED     3594     /dev/socket/agpsd
unix  3      [ ]         STREAM     CONNECTED     3593
unix  3      [ ]         STREAM     CONNECTED     4235     /dev/socket/mdns
unix  3      [ ]         STREAM     CONNECTED     4234
unix  3      [ ]         STREAM     CONNECTED     4185     /dev/socket/netd
unix  3      [ ]         STREAM     CONNECTED     4184
unix  3      [ ]         STREAM     CONNECTED     4182     /dev/socket/vold
unix  3      [ ]         STREAM     CONNECTED     4181
unix  3      [ ]         SEQPACKET  CONNECTED     3530
unix  3      [ ]         SEQPACKET  CONNECTED     3529
unix  3      [ ]         SEQPACKET  CONNECTED     3521
unix  3      [ ]         SEQPACKET  CONNECTED     3520
unix  3      [ ]         SEQPACKET  CONNECTED     3115
unix  3      [ ]         SEQPACKET  CONNECTED     3114
unix  3      [ ]         STREAM     CONNECTED     280      /dev/socket/installd
unix  3      [ ]         STREAM     CONNECTED     992
unix  3      [ ]         STREAM     CONNECTED     2223
unix  3      [ ]         STREAM     CONNECTED     2222
unix  3      [ ]         SEQPACKET  CONNECTED     383
unix  3      [ ]         SEQPACKET  CONNECTED     382
unix  2      [ ]         DGRAM                    352
unix  2      [ ]         DGRAM                    349
unix  2      [ ]         DGRAM                    339
unix  3      [ ]         STREAM     CONNECTED     270
unix  3      [ ]         STREAM     CONNECTED     269
unix  3      [ ]         STREAM     CONNECTED     1551
unix  3      [ ]         STREAM     CONNECTED     1550
unix  3      [ ]         STREAM     CONNECTED     1548
unix  3      [ ]         STREAM     CONNECTED     1547
unix  3      [ ]         STREAM     CONNECTED     124
unix  3      [ ]         STREAM     CONNECTED     123

ports.conf (ubuntu environment)

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Buffer/Cache use 100% Memory

I have a Linux box installed centos 6.6 with 7 GB RAM running Apache on top of it, every night Buffer and cache consume 6 GB memory out of 7 GB but when i check it through top command no process use that much RAM but only Buffer/Cache does...please help.

Print floats in nasm without binding to C functions

I'm wondering, how to print float numbers in nasm using only syscalls in linux. I have the following code, but it prints only @

section .data
  num dq 2.0
  len equ $ - msg

section .text
global _start
_start:
  mov edx, len
  mov ecx, num
  mov ebx, 1
  mov eax, 4
  int 80h

  mov eax, 1
  int 80h

Who to make it right?

vendredi 8 mai 2015

Work around for multidimensional arrays in bash?

I am currently not comprehending arrays in bash *nix. I have worked mainly with php. I have struggled to understand how to loop through multidimensional arrays. From some basic research I see that bash doesn't deal with multidimensional arrays. Is there a work around? How can I replicate the below php to bash?

PHP example

$social_media = array( array( 'seconds' => 15, 'social' => 'Instagram'  ), array( 'seconds' => 7, 'social' => 'Vine'  ), array( 'seconds' => 10, 'social' => 'Snapchat'  ) );

foreach ($social_media as $value) {
    echo "{$value['social']} allows for videos to be {$value['seconds']} seconds long.</br>\n";
}

CPU performance in android from jni

To my understanding I believe CPU performance is measuring the user space and kernel space if I am right please do let me know in which file and field I can get the above required information so that I can read it from the same.

Is there a better way to measure CPU performance ??

How can we measure CPU performance in Android ??

WHICH /proc file contains details about CPU performance ??

Creating comma seperated list of paths (allowing for spaces in path), and passing result as a variable to use again

I have come close to working this out myself but always seem to come up short.

Basically what I want to achieve is to sort out torrents using a command line program that can output paths (or hashes, names etc) based on certain criteria. I'd like to be able to only choose the torrents that satisfy that criteria but DO NOT share a path with another torrent. There is no way that I know of to know what these are beforehand. So command would have to be repeated a few times, passing the result of the previous call in as a formatted variable to the next call.

For example

rtcontrol ratio=+2 completed=+5d -qopath

will output

/home/user/path/name1
/home/user/path/name2
/home/user/path/name 3
/home/user/path/name 3
/home/user/path/name 4
/home/user/path/name5

This has the chance to produce duplicate paths which are not needed and should be filtered out by using something like uniq -u

I would then need to convert that list to a comma separated list of paths, but allowing for spaces in the path if they occur, e.g.

"/home/user/path/name1","/home/user/path/name2","/home/user/path/name 3","/home/user/path/name 4","/home/user/path/name5"

This will then have to be passed on as a variable to the same program again to get a list of torrents that have one of those paths. Once again there can be duplicates as output, e.g.

#Assuming the results of the previous called are stored in a variable named PATHS
rtcontrol path=$PATHS -qopath

with output of

/home/user/path/name1
/home/user/path/name2
/home/user/path/name 3
/home/user/path/name 3
/home/user/path/name 4
/home/user/path/name5

The reason for this is it is possible that a torrent DOES NOT satisfy the conditions or ratio=+2 completed=+5d, but has the same path as one that DOES. This is the reason for the second call rtcontrol path=$PATHS -qopath

Now what I would need to do is take the output of this as a variable and remove EVERY duplicate path again which should leave me with a list of torrents that satisfy both those conditions.

I would then pass this to one last call to get a list of torrents that fulfill the first requirement, don't share a path with a torrent that may or may not also fulfill those requirements like so, and perform an action on them.

#Assuming the results of the previous called are stored in a variable named PATHS2
rtcontrol path=$PATH2 --cull

I have tried different combinations of uniq, sed and awk as well as using pipes to pass along output. It should be noted that rtcontrol output can be piped out e.g. rtcontrol name="*Test* -qoname|uniq -u

I hope this is not confusing, and there is probably multiple ways to handle it. I'm just looking for the most efficient and flexible way to achieve it. I'm not sure it can be done in any less than the 3 main steps, due to what arguments the program can take, and what it can output. The specifics of each step and handling the output and input are what has me stumped.

This can be handled in pure bash, or with Python. There are also python libraries to interface with the torrent program that can perform similar functions, and even more advanced things that I am investigating.