Affichage des articles dont le libellé est Active questions tagged linux - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged linux - Stack Overflow. Afficher tous les articles

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!