linux

using mono-service to wrap a windows service on linux

Hi I'm trying to use mono-service2 to run a stock Windows Service Project from visual studio. I'm running this on debian with mono 2.0 and compiling with. gmcs *.cs -pkg:dotnet I try and start with this (I've tried with -d set to the dir with the app and -n,-m set) mono-service2 -l:service.lock --debug Program.exe The only code cha...

How to pretty-print JSON script?

Is there a (*nix) command-line script to format JSON in human-readable form? Basically, I want it to transform the following: { foo: "lorem", bar: "ipsum" } ... into something like this: { foo: "lorem", bar: "ipsum" } Thanks! ...

/usr/bin/env questions regarding shebang line pecularities

Questions: What does the kernel do if you stick a shell-script into the shebang line? How does the Kernel know which interpreter to launch? Explanation: I recently wanted to write a wrapper around /usr/bin/env because my CGI Environment does not allow me to set the PATH variable, except globally (which of course sucks!). So I thou...

configure ip alias and route, deal with network unavailable

I need to write a script to set ip address/mask/broadcast as an alias on eth0:0 plus set the default gateway. This solution works: ifconfig eth0:0 <ip> netmask <mask> up ip route replace default via <ip> but sometimes the second call gets an error "network unavailable". Adding a sleep between them fixes it, but is unreliable. What i...

How to access to parent widget on qt?

I have an inherited QTreeWidget (called PackList) class and its parent is a KXmlGuiWindow. How can I access to the parent's slots? I've tried getParent()->mySlot() from the QTreeWidget class but I've got error: no matching function for call to 'PackList::mySlot()' Does anybody know the correct way? Thanks ...

How to add file extensions based on file type on Linux/Unix?

This is a question regarding Unix shell scripting (any shell), but any other "standard" scripting language solution would also be appreciated: I have a directory full of files where the filenames are hash values like this: fd73d0cf8ee68073dce270cf7e770b97 fec8047a9186fdcc98fdbfc0ea6075ee These files have different original file types...

Getting data from a QTreeWidgetItem inherited class

I have a class which inherits from QTreeWidgetItem and I intercept the click event. I need to get another object from inside MY QTreeWidgetItem when I click the tree row, how can I do that?? ...

Making Python default to another version installed on a shared host.

I am on a shared host and can not change the symbolic link to Python2.4, it defaults to 2.3. I tried creating a sym link in the director I would be working on to 2.4, but it seems the the 'global' python interpreter under /usr/bin/python take presedence unless I run it as ./python. What alternative ways are there to override this behavio...

using regex to find files with certain extensions

What's the regular expression I could use with find -regex to find all files that have a .xls or .csv extension? ...

qt/c++ casting question

I have a QVariant object within a QTreeWidgetItem, how can I cast it to my own object? ...

Oracle linux front end

Hello is there any Oracle database ( around version 10 ) front end that we can use in Linux. free or open source? I am currently using Ubuntu 8.10 and if possible I just want it to need the thin JDBC to connect to oracle and not the whole ( huge ) client of oracle installed in it. Thanks ! ...

How to output MySQL query results in csv format?

Is there an easy way to run a MySQL query from the linux command line and output the results in csv format? Here's what I'm doing now: mysql -u uid -ppwd -D dbname << EOQ | sed -e 's/ /,/g' | tee list.csv select id, concat("\"",name,"\"") as name from students EOQ It gets messy when there are a lot of columns that need to be...

QVariant and qRegisterMetaType question

I have a class Pkg and I need to use it under form of QVariant. At the end of my Pkg.h I have: Q_DECLARE_METATYPE(Pkg) and this does not give compile errors, but in my main.cpp I have to do: qRegisterMetaType<Pkg>("Pkg"); and this does not give errors too, but when I try to create a QVariant(Pkg) I get lots of errors like: In me...

Sorting multiple keys with Unix sort

I have potentially large files that need to be sorted by 1-n keys. Some of these keys might be numeric and some of them might not be. This is a fixed-width columnar file so there are no delimiters. Is there a good way to do this with Unix sort? With one key it is as simple as using '-n'. I have read the man page and searched Google ...

Function like SetFileLength() in C Library for Linux

Is there a function in the C Library under Linux which can set the length of a file? Under Windows I know there is a SetFileLength() function. If there is not, what is the best way of shortening a file without deleting and rewriting it? ...

Is there a non-scripting language for Linux/Apache?

I'm familiar with a number of web based languages out there, and a number of them are scripting (ASP, JSP, ColdFusion, PHP, etc). On the Windows platform, the single biggest move with ASP.NET is the move away from a scripted language. Is there a non-scripted language for Linux (LAM+?). Anything anyone out there is using to do this? Is...

Special Meaning for Pointer Value 0x7c7c7c7c

While debugging a Linux app, I found a pointer with the suspicious value 0x7c7c7c7c. Does that particular value indicate anything? (I ask because I know from my MSVC days that in a debug build, values like 0xcdcdcdcd or 0xdddddddd would be stored into heap blocks that were uninitialized, freed, or otherwise invalid. Some people use ma...

Git repository with multiple users on Ubuntu

I have an existing bare git repository located in /home/myaccount/git/project. I am currently using it over ssh from my local machine without any problems. I want to add a second user on the server which only shall access to this git repository (maybe move the repo outside my account folder?). How? Using latest version of git and ubuntu ...

What GUI toolkit looks best for a native LAF for Python in Windows and Linux?

Hello I need to decide on a GUI/Widget toolkit to use with Python for a new project. The target platforms will be Linux with KDE and Windows XP (and probably Vista). What Python GUI toolkit looks best and consistent with the native look and feel of the run time platform? If possible, cite strengths and weaknesses of the suggested toolk...

Why does the following print 'Resource temporarily unavailable'?

Why does the following code print ‘read(): Resource temporarily unavailable’ 80% of the time? That is the EAGAIN code, which is the same as WOULD BLOCK which means there is no data waiting to be read, but select is returning 1 saying there is data (tested in Linux): #include <time.h> #include <unistd.h> #include <stdio.h> #include <stri...