linux

Bind application to several Linux terminals

I have an application which spawns several processes. Is it possible to redirect the output of the children to another hidden terminal so that it does not mix with the parent output and give the ability to the end user to unhide the terminal when needed? Thanks. ...

Truncating a file while it's being used (Linux)

I have a process that's writing a lot of data to stdout, which I'm redirecting to a log file. I'd like to limit the size of the file by occasionally copying the current file to a new name and truncating it. My usual techniques of truncating a file, like cp /dev/null file don't work, presumably because the process is using it. Is th...

What are the best practices for designing a Command Line Interface (CLI)?

I need to rollout an application in appliance form factor and have been asked to design a CLI as exposing BASH is problematic from a simplicity/usability perspective. I would like to understand the best practices for CLI development around: Security Configuration backup and restore Making it work not only via IP but also serial port Cr...

What are the best practices for building a front panel interface?

I have been asked to package an application in appliance form factor and would like to understand best practices around building a front panel interface. I am looking for guidance around: Design of the UI and menu system Making this type of code portable to multiple types of hardware Having a Java application send status information to...

Executing shell commands as given UID in Python

I need a way to execute the os.system() module as different UID's. It would need to behave similar to the following BASH code (note these are not the exact commands I am executing): su user1 ls ~ mv file1 su user2 ls ~ mv file1 The target platform is GNU Linux Generic. Of course I could just pass these to the os.system module, but h...

Imitating a context menu in Gtk#/gtk-sharp

Is there some way to use the Menu.AttachToWidget(...) function of a gtk menu item to attach the menu to say a Gtk.Textview and have it handle showing the menu when needed. Or is creating an event handler for ButtonPressEvent and showing the menu there the only way to do it? Or is there a third possibility that I'm missing? Thanks in Ad...

How to get network interface speed programactically on Linux?

I am wondering about the speed as show in the network connection information, e.g. 100Mb/s, 10Mb/s, not the available bandwidth. Thanks in advance! ...

Util-Linux Login not working with shadow password

I downloaded util-linux-2.12b package and and built it. I need to use the login utility in the login-utils folder. But after running it, it gives a "Login incorrect" for every user even with correct username/password. Now it seems the utility is not working with /etc/shadow passowrds. if I disable the shadow passwords by #pwunconv ...

Error installing ruby fastCGI binding in CentOS. How to avoid it ~>_<~

I have successful executed following commands: tar xzvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0 ./configure --prefix=/usr/local/fcgi make && make install tar xzvf ruby-fcgi-0.8.7.tar.gz cd ruby-fcgi-0.8.7 ruby install.rb config -- --with-fcgi-include=/usr/local/fcgi/include --with-fcgi-lib=/usr/local/fcgi/lib But I get this error when I r...

What does __sync_synchronize do?

I saw an answer to a question regarding timing which used __sync_synchronize(). What does this function do? And when is it necessary to be used? ...

Obfuscate strings in Python

I have a password string that must be passed to a method. Everything works fine but I don't feel comfortable storing the password in clear text. Is there a way to obfuscate the string or to truly encrypt it? I'm aware that obfuscation can be reverse engineered, but I think I should at least try to cover up the password a bit. At the very...

recursive folder scanning in c++

Hi I want to scan a directory tree and list all files and folders inside each directory. I created a program that downloads images from a webcamera and saves them locally. This program creates a filetree based on the time the picture is downloaded. I now want to scan these folders and upload the images to a webserver but I´m not sure how...

How to staticly-link a complex program

Hello, In Linux, downloaded a program source and want it to be statically linked. Have a huge Makefile there, I ./configure make to compile. prehpes it's a bit too general to ask, but how can I make the binary statically linked? Thanks. EDIT: the reason for this is wanting to make sure the binary will have no dependencies (or at le...

how to convert ai to cdr for linux

hi all; I need ai or eps files to cdr file command line converter. ...

How can I hook into tcsh's TAB completion on Linux

I have some directories with a number of "hidden" files. One example of this is I'm in a source controlled sandbox and some of the files have not been checked out yet. When I hit TAB, I'd like the option of seeing these files. A similar question has been asked before: CVS Tab completion for modules under linux The answers to that quest...

Forcing non-cached gethostbyname()

Hi. Is there any way to prevent the gethostbyname() function not to read the nscd cache on Linux? Thanks in advance! ...

Shell command to tar directory excluding certain files/folders

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very large files I do not need to backup. Not quite solutions: The tar --exclude=PATTERN command matches the given pattern and excludes those fi...

Path sanitization in C++

I'm writing a small read-only FTP-like server. Client says "give me that file" and my server sends it. Is there any standard way (a library function?!?) to make sure that the file requested is not "../../../../../etc/passwd" or any other bad thing? It would be great if I could limit all queries to a directory (and its subdirectories). ...

How to make a Linux Service that Accepts Commands via Web Server?

I need an application to be running in the background on my web server, but I need to be able to start/stop the application with root privileges. In order to do this, I want to have a service running that has root privileges, so that it can kill the application, and start it up again if need be. Finally, I need to be able to send the s...

Padding Empty Field in Unix Join Operation

I have two files where I want to perform union operation based on 1st column: file1.txt foo 1 bar 2 qux 3 file2.txt foo x qux y boo z The result I hope to get is like this: foo 1 x bar 2 - qux 3 y boo - z where the empty fields of column 1 is padded with "-". But why this join command doesn't work as I expected? $ join -a...