linux

Change script directory to user's homedir in a shell script

In my bash script I need to change current dir to user's home directory. if I want to change to user's foo home dir, from the command line I can do: cd ~foo Which works fine, however when I do the same from the script it tells me: ./bar.sh: line 4: cd: ~foo: No such file or directory Seams like it would be such a trivial thing, b...

How to develop a DirectFB app without leaving X.11 environment.

Hi folks, I'm trying to develop a GUI application for an embedded platform, without any windowing whatsoever and I'm doing that with DirectFB, and it suits my needs very fine. Since the embedded I develop for is not that powerful, I would really like to try to develop on my own Ubuntu desktop. The problem is Framebuffer is conflicting ...

Concatenating to Clipboard?

Does anyone know of a utility (for Windows or Linux or MacOSX) that will append the selected contents to the clipboard? Rather than killing what's already there...(maybe using a different keyboard shortcut instead of Ctrl+C to do this? And I don't mean multiple-clipboard items... I mean concatenating multiple strings of text to the sam...

How do you specify a tab in .screenrc?

According to this website, you can change to command key sequence used by the Unix "screen" utility like this: escape ^Bb # Instead of Control-a, make the # escape/command character be # Control-b How would you make it Control-Tab, I wonder? ...

Insert Command into Bash Shell

Is there any way to inject a command into a bash prompt in Linux? I am working on a command history app - like the Ctrl+R lookup but different. I am using python for this. I will show a list of commands from history based on the user's search term - if the user presses enter, the app will execute the command and print the results. So fa...

AJAX Progress: Reading output from the Shell

Hello all, Objective: Make a progress bar where users can check how much of a file has been downloaded by my server. Scenario:I have a PHP script that executes a python script via popen. I have done this like so: $handle = popen('python last', 'r'); $read = fread($handle, 4096); pclose($handle); This python script outputs to the s...

In which situations is it advisable to opt for BSD systems instead of Linux?

For an everyday-user with new hardware Linux seems for me the natural choice if somebody is looking for an alternative to Windows. But when does it make sense to give the BSD variants a try? ...

Simple GUI IDE?

Hi I'm looking for a GUI Linux IDE. Specs: simple and fool proof. normal look & feel full as-you-type indentation in most languages a compile+run button, a debugger, auto-refactoring for C++ basic unintrusive support for common buildsystems - straight make, cmake, qmake, autotools smooth workflow. proper keyboard support, no jarring ...

rdts to mark time deadlines

I have a code that "sounds" like this: thread 1 now = rdtsc(); for_each_member_in_a_list { if ( member_in_list.deadline() <= now ) { do_something; } } thread 2 now = rdtsc(); for_each_member_in_a_list { member_in_list.updatedealine( foo(now, ...) ); } now while this was working good in the past now with a SMP system...

LINUX: Is it possible to write a working program that does not rely on the libc library?

I wonder if I could write a program in the C-programming language that is executable, albeit not using a single library call, e.g. not even exit()? If so, it obviously wouldn't depend on libraries (libc, ld-linux) at all. ...

pthread conditional variable

I'm implementing a thread with a task queue. As soon as as the first task is added to the queue the thread starts running it. Should I use pthread condition variable to wake up the thread or there is more appropriate mechanism? If I call pthread_cond_signal() when the other thread is not blocked by pthread_cond_wait() but rather doing...

Is there a way to start/restart/stop apache server on linux as non-root user?

I'd like to know if it is possible for non-root user on linux (i'm using openSUSE) to run apache without using sudo command. Take into account that the user is in the same group as apache (wwwrun). Thanks in advance. ...

Window message procedures in Linux vs Windows

In Windows when you create a window, you must define a (c++) LRESULT CALLBACK message_proc(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam); to handle all the messages sent from the OS to the window, like keypresses and such. Im looking to do some reading on how the same system works in Linux. Maybe it is because I fall a bit...

Should I use c++ or script for a daemon process?

I need to implement a daemon that needs to extract data from a database, load the data to memory, and according to this data perform actions like sending emails or write/update files. These actions need to be performed every 30 minutes. I really don't know what to decide. Compile a c++ program that will do the task or use scripts and mi...

Finding processes using ALSA sound fast

Currently the way /usr/sbin/alsa in Debian knows the processes using the sound card looks like: echo $( \ lsof +D /dev -F rt \ | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ && type == "tCHR" {print pid}' \ | cut -c 2- \ | uniq \ ) Which is rather ugly and depends on lsof. I am looking for a POSIX solution without lsof, perha...

Possible to abort shutdown on Linux?

I'm familiar with and use shutdown in Linux, and typically just do > shutdown -h now But is there a way to stop shutdown from happening, say if I aim to shutdown 10 minutes from now and then in 5 minutes time I discover I really don't want to shut down? ...

How can I make a public HTML folder in Ubuntu?

Simple question, but for some reason I couldn't find the exact answer on Google: I have a fresh Ubuntu install on Slicehost, and would like to make a public directory in my home dir for a simple website containing a bunch of static HTML files. How do I do this? Is it just a matter of typing mkdir public_html and setting the permissions,...

How to deal with duplicate code under Linux?

I'm looking for the best approach to dealing with duplicate code in a legacy PHP project with about 150k lines of code. Is this something best approached manually or are there standalone duplicate code detectors that will ease the pain? ...

How to restrict a linux user to be only able to read /home/user and nothing else

Hi, I need to create a special linux user account that has a very limited set of permissions on the system. Essentially to have read-only permissions for his home dir (and sub dirs) and nothing else - i.e. this user has no write or execute permissions and should not be able to read/access other user dirs or indeed anything outside of hi...

What should Linux/Unix 'make install' consist of?

I've written a C++ program (command line, portable code) and I'm trying to release a Linux version at the same time as the Windows version. I've written a makefile as follows: ayane: *.cpp *.h g++ -Wno-write-strings -oayane *.cpp Straightforward enough so far; but I'm given to understand it's customary to have a second step, make...