Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.

learn more… | top users | synonyms

5
votes
2answers
56 views

Writing a utility class for converting between datetime and timestamp

I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 ...
1
vote
1answer
51 views

Non-blocking Unix domain socket

I've developed quickly two kinds of socket use: the first with blocking mode and the second with non-blocking mode. The sockets are Unix domain sockets. My problem is that the kernel consume a huge ...
2
votes
2answers
73 views

Set-uid root program that runs a program as the user “restrict” (follow-up)

See Set-uid root program that runs a program as the user "restrict" for context. I've written a very short program that is intended to run the program specified in its arguments (...
0
votes
1answer
29 views

Set-uid root program that runs a program as the user “restrict”

I've written a very short program that is intended to run the program specified in its arguments (argv) as the user named "restrict" (which exists). I want to make ...
7
votes
1answer
57 views

Portable method of getting time in C

Mac doesn't have the Unix clock_gettime so I am trying to create something that's really portable and only dependent on C. So far I've come across this function: ...
4
votes
3answers
67 views

Fetching filesystem directory listings on a server

I developed a server which takes a directory name then lists files in it and sends this list to a client. And I want that server to work with Telnet. It works but I have some questions on how I can ...
1
vote
1answer
39 views

Unix shell script with master and source files

I have a script which is having too many modules. The script is working perfectly, but the only issue is it is taking too much time and I need to reduce the complexity of the script. I have a source ...
4
votes
2answers
88 views

A simple fork with an ugly waitpid

This is my first take on fork, exec and waitpid. I didn't quite understand why I had to use ...
4
votes
1answer
118 views

A simple C++ trading system demo

I need my trading system demo reviewed. It implemented a simple system which parse the trading flow (logged in file) of different trader and calculate some important feature. The code is listed here ...
8
votes
1answer
203 views

A rapidly-growing script that visualizes WiFi sniffing

Below is one of the versions of my wifimap script: ...
2
votes
3answers
357 views

Unix shell function for adding directories to PATH

Adding a directory to the PATH in Unix/Linux is a very common task. However, what if the directory is already in the path? My goal is to write a shell function ...
2
votes
2answers
52 views

A trivial command line utility for trimming whitespace from lines in C - follow-up 3

The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up 2 Now my code looks like: ...
1
vote
1answer
54 views

A trivial command line utility for trimming whitespace from lines in C - follow-up 2

The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up Note: the next iteration at A trivial command line utility for trimming whitespace from ...
3
votes
2answers
58 views

A trivial command line utility for trimming whitespace from lines in C - follow-up

See the previous iteration: A trivial command line utility for trimming whitespace from lines in C Note: see the next iteration at A trivial command line utility for trimming whitespace from lines in ...
3
votes
1answer
55 views

A trivial command line utility for trimming whitespace from lines in C

I was practicing some C and decided to write this simple command line utility for stripping leading and trailing white-space characters. Note: see the next iteration at A trivial command line utility ...
1
vote
1answer
103 views

Python script that launches a process that it needs to clean up after and kill on receiving SIGTERM/SIGINT

I'm using a Python script to run a particular program that occasionally may need to be terminated (by receiving a SIGINT or SIGTERM) in which case a clean up process needs to be invoked (before ...
4
votes
3answers
44 views

Security feedback sought on Perl code running command on unsafe filename in Unix env

I'm looking for security feedback on the following fully functional code. The code is trying to safely use the Unix 'file' command to give details about the file. A hard link is used to create a ...
2
votes
1answer
91 views

HTTP client similar to cURL

I'm writing my own HTTP client, kinda like cURL. (I already know I'm reinventing the wheel, this is more or less getting an inside look of HTTP 1.x before 2 becomes a thing.) So far pages download ...
4
votes
2answers
510 views

Function to grab stdin, stdout, stderr of a child process

I've managed to create a function to pipe the stdin, stdout and stderr of a child process ...
4
votes
1answer
76 views

Find-grep-sed for project-wide search & replace

I always forget how to do this efficiently with Vim's arglist. Drawing inspiration from a post over at Stack Overflow, I wrote a Bash function to perform a project-wide search & replace. It does ...
8
votes
2answers
889 views

MySQL class to add user/database

I'm creating tool to add new virtualhost on UNIX-box. One of tasks is to add a new user and database to MariaDB (aka MySQL) server. In fact - this my first 'real' attempt to use OOP. Here is class, ...
4
votes
1answer
77 views

Pathname matching and listing program

This Python 3 program outputs a list of all pathnames in the filesystem that match a list of rules taken from a file. You can add and remove sets of pathnames. The original purpose was to generate ...
7
votes
1answer
71 views

Unix 'sleep' clone - unsure of safety

I decided to try making some simple clones of the various user-space Unix utilities in an effort to learn the system-specific headers and improve my C skills. The code that follows is a clone of ...
8
votes
1answer
1k views

Split large file into smaller files

I recently suggested this method for emulating the Unix utility split in Python. Is there a more elegant way of doing it? EDIT: Assume that the file chunks are too large to be held in memory. Assume ...
5
votes
2answers
5k views

Small bash script to start and stop named services

I've been working on ubuntu since many years but not quite familiar with bash scripting. My development tools involve servers like nginx and apache, the mysql database and beanstalkd. Obviously, I ...
4
votes
3answers
855 views

Clean way to get size of directory

I'm working on a Unix machine where I can't use more than vanilla Perl, and I'm using Perl5.8. This script exits with a 1 if the current directory size is smaller than 1 GB (the character after ...
4
votes
1answer
246 views

Bash Music Player

I have finally finished creating my first real project. It's just a simple music player that can provides the user with the latest music from any site (as long as it contains MP3 files) he provides ...
5
votes
1answer
3k views

Implementing the 'cat' command

The options for the 'cat' command are as follows: ...
3
votes
2answers
150 views

Removing NULL / empty fields

just wanted to check with you could this be done better: ...
5
votes
1answer
133 views

Portability and “dark corner” gotchas in this “watchdog” program

The following program is intended to "watchdog" a child process, and all subprocesses the child spawns. The intended behavior is: A child process (as specified on the command line) is run in a ...
4
votes
1answer
433 views

List contents of a folder using a shell script and mail the folder

I want to list the contents of a folder and mail the list using a shell script. I Came up with the following script, please let me know if it is okay: ...
2
votes
1answer
123 views

Bash script to manage multiple Java Development Kits installations

I'm writing a bash script to manage multiple JDKs, the script is very simple, you have to choose a directory when you store all the jdk's, and the script maintain ...
5
votes
2answers
98 views

Make a directory and change to it

A basic shell function to create a directory and change to it goes like this: mkcd () { mkdir "$1" && cd "$1"; } This works well in many cases but breaks ...
3
votes
2answers
650 views

Symlinking git-managed dotfiles into a home directory

As a learning exercise, I decided to write a script for helping me maintain my Unix configuration/dot-files under a git repository. I check out a copy of the repository in my home directory called ...
1
vote
1answer
586 views

How can I further optimize this Perl script for finding all unowned files and directories on Unix?

(Originally posted on Stack Overflow) Following my findings and suggestions in my other post How to exclude a list of full directory paths in find command on Solaris, I have decided to write a Perl ...