linux

How to get line count from variable (from MYSQL query)?

My problematic code: testMYSQL=`mysql -u $mysqlUser -p$mysqlPass -h $mysqlHost --skip-column-names --batch -D $mysqlDB -e "SELECT $select FROM $mysqlTable WHERE nameTXT='test';"` $testMYSQL now contains: test test test Then I do: TEST=$(echo $testMYSQL | wc -l) echo "$TEST" I would of thought that would work, but it doesn...

Are there any lint tools for C and C++ that check formatting?

I have a codebase that is touched by many people. While most people make an effort to keep the code nicely formatted (e.g. consistent indentation and use of braces), some don't, and even those that do can't always do it because we all use different editors, so settings like spaces vs. tabs are different. Is there any standard lint tool...

How can I find out the original username a process was started with?

There is a perl script that needs to run as root but we must make sure the user who runs the script did not log-in originally as user 'foo' as it will be removed during the script. So how can I find out if the user, who might have su-ed several times since she logged in has not impersonated 'foo' at any time in that chain? I found an i...

Mismatch between the program and library build versions detected

I built wxWidgets on Linux using this command: ../configure --enable-shared --disable-debug It see results of this build: /usr/local/lib/wx/config/gtk2-ansi-release-2.8 /usr/local/lib/wx/include/gtk2-ansi-release-2.8/wx/setup.h wx-config output: alex@alex-linux:~$ wx-config --list Default config is gtk2-ansi-release-2.8 Defa...

How to get text from the screen in KDE development

I want to get text from screen (like Babylon). Is there any thing to be helpful in KDE developement. Any api or library? Thanks in advance ...

Ruby script as service

Well, the title say it all. I have a ruby script I want running as a service (one I can start and stop) on my Linux box. I was able to find how to do it on Windows here Some readings point to creating daemons or cron tasks. I just need something simple I can call on my box's reboot, and can stop/start whenever I please. my script has a...

Remove line from a file using a variable line number

Hi Guys, This is probably a simple one to answer, but I'm stuck, so here goes. sed '3d' filename # (or something like that) I'm having trouble trying to use a $VARIABLE instead of the number. Anyone know how to get this to work, or any alternative options? Regards Paul ...

Need help modifying C++ application to accept continuous piped input in Linux

The goal is to mine packet headers for URLs visited using tcpdump. So far, I can save a packet header to a file using: tcpdump "dst port 80 and tcp[13] & 0x08 = 8" -A -s 300 | tee -a ./Desktop/packets.txt And I've written a program to parse through the header and extract the URL when given the following command: cat ~/Desktop/packet...

How do executables on Linux know where to get data files?

Programs on Linux install data for programs into $PREFIX/share/programname, how does the program know where that is, does it need to be compiled in? Would it be suitable to assume that the binary is in $PREFIX/bin, and use that to determine $PREFIX? This only needs to work on Linux, and specifically, I am using C. ...

What types of Linux skills does a typical PHP developer need?

I am trying to improve my programming skills by learning more about frameworks, methodologies, and related technologies. I have seen a lot of job postings with requirements that also include Linux and/or Apache. So, my question is, what sort of things should I study in terms of Linux from a development standpoint? ...

How can I get a list of licenses from intalled RPMs?

We've been asked to list all the software and licenses used in our organization. Without deciding the value of this request, I'd like to get my Fedora laptop to answer the question easily. rpm -qa Gives me a list of packages, but no license data. My next step is to take that output and write a script to query each package's license. ...

What's the best tool to do text processing in Linux or Mac?

I generally need to do a fair amount of text processing for my research, such as removing the last token from all lines, extracting the first two tokens from each line, splitting each line into tokens, etc. What is the best way to perform this? Should I learn Perl for this? Or should I learn some kind of shell commands? The main concern...

DST change handling in a daemon process (*NIX)

In a *NIX environment, if I have a 24x7 running application, how do I handle DST changes? I am looking for a solution for my app written in C/C++. ...

I SVN updated, but I realize I messed up.

How do I rollback to a previous revision? So that my files are back to revision 400? ...

Using pthread to perform matrix multiplication

I have both matrices containing only ones and each array has 500 rows and columns. So, the resulting matrix should be a matrix of all elements having value 500. But, I am getting res_mat[0][0]=5000. Even other elements are also 5000. Why? #include<stdio.h> #include<pthread.h> #include<unistd.h> #include<stdlib.h> #define ROWS 500 #defi...

What to use to check html links in large project, on Linux?

I have directory with > 1000 .html files, and would like to check all of them for bad links - preferably using console. Any tool you can recommend for such task? ...

Append all logs to /var/log

Application scenario: I have the (normal/permanent) /var/log mounted on an encrypted partition (/dev/LVG/log). /dev/LVG/log is not accessible at boot time, it needs to be manually activated later by su from ssh. A RAM drive (using tmpfs) is mounted to /var/log at init time (in rc.local). Once /dev/LVG/log is activated, I need a good w...

IMAP server for local develompent/testing

I'm developing application that will read messages from IMAP server.. what would you recommend for local development/testing (easy configurable light server) Platform - Ubuntu Linux ...

Same memory space being allocated again & again

In each loop iteration, variable j is declared again and again. Then why is its address remaining same? Shouldn't it be given some random address each time? Is this compiler dependent? #include<stdio.h> #include<malloc.h> int main() { int i=3; while (i--) { int j; printf("%p\n", &j); } ...

can dbxtool run more than one instance under the same user account?

At work we tend to all use the same useraccount on a development system - this means we can only have one instance of dbxtool running at a time! If you run as a different user then you are unable to attach to running processes that belong to the main user account. Apart from habitually running dbxtool as root, is there a way to force m...