unix

Tab Completion feature in unix shell development

hi to all i am developing a shell using unix system programming (robbins and robbins) how can i add this feature and also how can i add history feature too (history feature like in BASH- when i press up key it shows the previous typed command ) ...

Select() system call in threads?

Hi all, I am reading data from multiple serial ports. At present I am using Custom signal handler (by setting sa_handler) to compare and wake threads based on file descriptor information. I was searching for a way out to have individual threads with unique signal handlers, in this regard I found that select system call is to be used. N...

Java exec on Unix

I have the Java code below running on Unix (both AIX and Linux), but it doesn't work. If I run this code the file q1.01 is not compressed, and I don't get any exceptions thrown (The file q1.01 exists, and I expect to find the file q1.01.Z after the command runs.) At the command prompt if I type "which compress" it reports back with "/usr...

Why do I need setuid(0) within a setuid-root C program that calls an administrative program with system()?

I had to do a dirty Linux hack for somebody so they could start a printer with the cupsenable printername shell command while being a non-root user. I didn't want them to be able to use the entirety of the cupsenable syntax as root, so I just wrote a C wrapper that sanitizes the input in argv[1] and calls system("cupsenable sanitizedprin...

C Runtime objects, dll boundaries

Hi, What is the best way to design a C API for dlls which deals with the problem of passing "objects" which are C runtime dependent (FILE*, pointer returned by malloc, etc...). For example, if two dlls are linked with a different version of the runtime, my understanding is that you cannot pass a FILE* from one dll to the other safely. ...

Custom command line utility. How?

Recently, I've released an open-source class - wrapper of API functions available from one of the leading SMS gateway, which provides an HTTP-API access to send an SMS messages. Now I want to make a custom command line utitity, which can be available for user anywhere in the command line, so he can send SMS just by running console comma...

GNU readline History feature

I'm using this code for the history features in my shell: http://cc.byexamples.com/20080613/gnu-readline-how-to-keep-a-history-list-of-entered-command-lines/ but when I compile this using gcc, I got this error $ gcc filename.c /tmp/ccay2CgM.o: In function `main': rl.c:(.text+0x9): undefined reference to `rl_abort' rl.c:(.text+0x13): u...

Porting Unix ada app to Linux: Seg fault before program begins.

I am an intern who was offered the task of porting a test application from Solaris to Red Hat. The application is written in Ada. It works just fine on the Unix side. I compiled it on the linux side, but now it is giving me a seg fault. I ran the debugger to see where the fault was and got this: Warning: In non-Ada task, selecting an A...

PHP exec pgp command

I am want to use PHP to 'exec' a pgp encryption command. Regardless of the command line I get either a err 64 (parser error) or 162 (complete failure during an encode). So I have reduced the command line within the PHP program to this simple fingerprint display which stills errs out: exec("/opt/pgp/bin/pgp --fingerprint", $results); I...

How come the unix locate command still shows files/folders that aren't there any more?

I recently moved my whole local web development area over to using MacPorts stuff, rather than using MAMP on my Mac. I've been getting into Python/Django and didn't really need MAMP any more. Thing is, I have uninstalled MAMP from the Applications folder, with the preferences file too, but how come when I run the 'locate MAMP' command i...

Multiple random number generator states in c/Unix

I'm using srandom() and random() to generate random numbers in c on a Unix system. I would like to have multiple RNGs. Each one, given the same seed, should output the same sequence. I would also like to save and restore the state of each one. Here's a pseudocode example: R1 = new_rng(5); //5 is the seed R2 = new rng(5); //5 is the ...

Linux Tool To Parse CSV files

Is anyone aware of a standalone command line program that can be used to parse CSV files? To do things like: csvparse -c 2,5,6 filename to extract fields from columns 2 5 and 6 from all rows. It should be able to handle the csv file format: http://tools.ietf.org/html/rfc4180 which means quoting fields and escaping inner quotes as app...

Getting unix timestamp in milliseconds in PHP5 and Actionscript3

In Actionscript, the Unix timestamp in milliseconds is obtainable like this: public static function getTimeStamp():uint { var now:Date = new Date(); return now.getTime(); } The doc clearly states the following: getTime():Number Returns the number of milliseconds since midnight January 1, 1970, universa...

Postfix alias for all user names?

Is there something you can put in /etc/aliases that will make postfix send all mail to one user, no matter what the username? ...

How I can get Unix files using ASP.NET?

Team, I started working with Microsoft .NET 3.5. then I have to obtain and show two Unix files in my project. please do you have any how do it? ...

How can I split a string if it is a MS-DOS type path OR Unix type path?

I have a string that represents a path to a directory. I want split the string if it is a unix type path or a ms-dos type path. How can this be done? For example: <?php $a = some_path1/some_path2/some_path3; // unix type path $b = some_path1\some_path2\some_path3; // MS-DOS type path $foo = preg_split("something", $a); // what rege...

UNIX Command to recursively change permissions on directories?

I just want to change permissions on directories, not the files contained within. ...

Is there a standard method to add to ENV variables conditionally on being empty?`

I am creating a script to configure and launch software. My current application requires appending to LD_LIBRARY_PATH. I know that I can test if this is empty first and set it outright and append it otherwise. The following does not appear to work and it keeps appending to the variable even if it contains the string I am testing for i...

What are the main *nix OS's which are good for learning *nix programming?

I want to learn to program in a UNIX/Linux environment. I'll be using the C, C++, and Perl programming languages (as well as learning bash, of course). I just keep getting fascinated over POSIX and other differences between Windows and *nix libraries (and also just bought the Perl Llama book), and I want to try programming for a differen...

shifting from windows to *nix programming platform

How to migrate to *nix platform after spending more than 10 years on windows? Which flavor will be easy to handle to make me more comfortable and then maybe I can switch over to more stadard *nix flavors? I have been postponing for a while now. Help me with the extra push. ...