Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [unix]

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

2
votes
1answer
41 views

Making a disk usage breakdown

I'm looking for a better way of doing this code I made. I work for tech support and one of the biggest questions I am asked is: "Hey, how did my disk get so full in my VPS?" I am aiming for output ...
3
votes
0answers
25 views

TextFileConvert - dos2ux and ux2dos in VB.NET

This provides text file conversion capabilities like the common Unix utilities "ux2dos" and "dos2ux". I needed the capability to perform Unix text file conversions, round trip, within a VB.NET ...
6
votes
2answers
171 views

Rot13 Unix Filter in C

I'm trying to brush up on some C basics (it's been ten years since I've programmed in C) and am working on a simple Rot13 program as a Unix filter. Any suggestions on how to improve it would be ...
2
votes
1answer
68 views

Analog of unix word count (wc) in Java

I wrote implementation of unix console program word count "wc" in Java. Please evaluate it. Is there any better solution? ...
1
vote
0answers
27 views

Create an XML using the CSV input [closed]

Aim : To create a xml file from the csv file I am trying to create a xml file from the csv file , the xml contains header , footer and body . I have create 3 different functions. Input csv file <...
8
votes
3answers
151 views

Platform independent whereis function

I'm trying to write a platform independent Python (>=3.6.5) package that has a handful of java .class files that need to compiled using javac and run using ...
7
votes
2answers
197 views

Bash script to temporarily run a shell without certain group memberships

I have here a script called rwog (run without groups) that allow a user to run a shell without particular group memberships. ...
4
votes
1answer
63 views

Safely trash instead of rm

This script is called trash and it goes on the path. Usage: trash [OPTIONS] [TRASH_FILES]... How clean/readable do you think ...
4
votes
2answers
193 views

Path traversal prevention in PHP

As with other inputs, file paths should be validated before thay could be passed to operating system interfaces. Since chroot(2) has a bit more than some ...
6
votes
2answers
1k views

Echo implemented in Java

I implemented a simple version of echo(1) command utility. The program works as described in the man page: it writes to the standard output all command line arguments, separated by a whitespace and ...
1
vote
1answer
60 views

Fortune of Unix V7 implemented in Java

I'm learning Java recently, this is one of my first program written in this language. I reimplemented a basic version of Fortune. This version prints to the standard output a randomly chosen line ...
3
votes
1answer
99 views

Implementation of unix utility tail in C

I've written a simple implementation of tail as part of reading The C Programming Language by Kernighan & Ritchie. The question states to write tail, which prints the last n lines of its input. ...
0
votes
1answer
59 views

Termios line editor for APL - part 2

This is the completely re-worked version of the APL line editor using termios raw mode. (Earlier version) All switch constructs have been replaced with tables of ...
5
votes
1answer
1k views

Safely and elegantly handling UNIX signals in Qt applications

When you search the web on how to gracefully shut down your Qt application when receiving SIGTERM, you are invariably directed towards this informative, yet ...
2
votes
2answers
291 views

Run 'N' Number of PHP Scripts on shell forever in a loop

My objective is to run some 'N' number of PHP Scripts in cron. Since these are web scrapers coded in PHP and hits database on my server, each script runs for like 1 hour and they take a lot of CPU ...
3
votes
1answer
381 views

Bash script to deploy a mongodb cluster on local machine

I recently wrote a small script to deploy a mongodb cluster on a single machine. The cluster is composed of : 3 configurations server that holds the same informations (they are replicas ) 2 shard ...
5
votes
1answer
41 views

Aligning fstab columns

I know I can use the unix column function to replicate 90% of the functionality here, so this is mostly just to practice python. I find a misaligned fstab file really hard to read. This script parses ...
1
vote
0answers
90 views

Run one Python script from another on Windows, Linux and Unix machines that use the same code

I have a series of rather complicated codes that I developed on a Linux machine, run on a Unix cluster and from time to time need to run on a Windows machine to gain access to a private network. They ...
8
votes
1answer
74 views

Spoofs MAC Address to manufacturer of user's choice, Linux or MacOS

I've made a BASh script for Linux/MacOS that allows you to search for a MAC manufacturer and then generates a MAC address from that company and then spoofs it to that using ...
1
vote
0answers
34 views

Secure local Interprocess communication

I wrote the SlipRock library for secure local interprocess communication. It is designed to be secure against untrusted users running on the same machine, or any user running on any other machine. ...
6
votes
1answer
518 views

Perl script to check disk usage and report via email

Due to lack of central configuration management I am avoiding any Perl modules which would need to be installed on each of a great many servers. Result is more code than would normally be required in ...
3
votes
1answer
52 views

Function that calls a function with the terminal temporarily set to raw mode

I'm working through Build Your Own Text Editor, a walkthrough of the code to an extremely small text editor for a posix terminal in C, but I'm attempting to follow along in-the-spirit with OCaml. I'...
2
votes
0answers
63 views

Plugin to fetch users from /etc/passwd

I am starting to try to conform to coding standards use exception handling. What do you think is missing here and what else should I consider further? The function ...
1
vote
1answer
660 views

Java executing rSync shell command with progress display

I basically want to write a simple GUI program to sync to directories using the rsync command. The core part of the code is below. My main question is, do I need to ...
8
votes
1answer
169 views

Python cat, aka Unix Meow

I have used linux and Windows interchangeably over the last time, and I got used to the more comfortable and options-rich syntax of linux' commands, so I decided to replicate some of them in python (...
5
votes
1answer
113 views

Get IP info from a FreeBSD machine

I'm try to get the public IP address from my FreeBSD machine and use it for the rest of my code. Is this implementation good? Can it be optimized more? Can you see some gaps here? Something that ...
2
votes
2answers
248 views

Simplify Unix path

Here is my code for simplifying a Unix path. Any advice is highly appreciated, including higher efficiency from an algorithm time complexity perspective, or any bugs. ...
2
votes
2answers
88 views

IPC using pipes

I have simulated the conversation between a caller and receiver using fork and pipe. The parent process is the receiver and the child process is the caller. Each message is terminated by a newline. ...
2
votes
1answer
110 views

Parsing GTF file using command-line

I am extracting exons details from a GTF file using command line in Unix like cut, awk, grep or sed. input file.gtf: ...
0
votes
1answer
42 views

Split a file into individually allocated lines

This is part of a larger project that is to run on POSIX systems. My concerns with it are the lack of comments, best practices with the filesystem, and naming things. Of course all feedback is great. ...
2
votes
1answer
104 views

GNU Makefile for google benchmark

I've decided to write a common Makefile for Google benchmark library. You could say I could have taken generated Makefile, but it's not appropriate solution (or maybe I'm wrong?). ...
2
votes
1answer
432 views

Shell script to archive files to AWS S3

This is a simple script that moves files to S3 if they are > 14 days old. It ignores files that are < 14 days old. If the file is successfully synced to AWS S3 then we can remove it from the server....
5
votes
1answer
29 views

Script to record an inventory of a backup

This is a script designed to make an inventory file which records the contents of a directory allowing verification that a backup has the same data. The same script can also A full github repo is ...
3
votes
1answer
501 views

C++ getaddrinfo()/addrinfo wrapper (rewrite)

As suggested by @Dannnno on my original post, I am posting my partially rewritten getaddrinfo() (and now addrinfo) wrapper for ...
6
votes
2answers
468 views

C++ getaddrinfo() wrapper

EDIT: New version can be found here: C++ getaddrinfo()/addrinfo wrapper (rewrite) I'm a C++ novice, but an experienced Python and C programmer. I decided to code a C++ wrapper around ...
2
votes
1answer
24 views

Shell command for the normal program termination of Skype from the command line

Would the following be the right way to do it in your opinion? Can you suggest a better alternative or, if not, is there something that can be done to make the existing version better? ...
6
votes
1answer
64 views

Automake for an S/KEY implementation

I've been tasked with giving a legacy codebase some love. The actual code is written in C, but is not very relevant aside from the #includes each file makes. No, ...
2
votes
1answer
80 views

C main function for POSIX shell

I got a pretty large main function that I want to break up in smaller helper functions. Can you help me suggest what to break out into helper functions? The ...
0
votes
1answer
39 views

Handle builtin commands

I've written a small C function to handle the builtin commands of a custom shell that I'm writing in C. Is it better to use a switch instead? ...
5
votes
4answers
18k views

Converting the DateTime to and from Unix epoch times

I'm currently working on a thing I needed this feature for. Essentially, these are two methods to convert DateTime objects to and from the Unix epoch time (two ...
3
votes
1answer
89 views

Display the last N lines of a text file with line numbers in reverse order

Do you think the way I'm doing it is fine? Is this the most typical way to do it? Share your thoughts please. ...
2
votes
0answers
359 views

A two-method program for running background jobs

Edit: since originally posting this I have: realized that it won't run from irb/pry, and refactored to remove some sleep calls. I've also separated the sections ...
4
votes
1answer
57 views

Making time lapse screenshots using Bash

My experience in bash is... well, around the Bourne shell on AIX. I wrote a semi-complex script in Bash, and I feel that it could be improved in 100 different ways. The Github project is here: https:/...
4
votes
3answers
103 views

Un*x terminal history wiper

Using various answers from Stack Overflow and Ask Ubuntu, I've hacked together this simple C program that wipes terminal history. It works but I'm relatively new to C so I'm not sure if everything is ...
1
vote
1answer
81 views

Measuring CPU frequency in *nix

I have this small function for reading the TSC (time-stamp counter) in *nix. Using it seems to report my CPU frequency more or less correctly. ...
1
vote
2answers
46 views

Program to let any user run a command

I have a script which can only be run by one specific user on a system. I need to let all users on the system have access to run that script and see the output. But there must never be more than one ...
4
votes
1answer
2k views

FFmpeg command line for showing two videos side by side

Here is command line for playing two videos side by side in sync in FFmpeg (ffplay). It can be useful for comaring videos, for example. ...
5
votes
1answer
173 views

Termios/Xterm line editor for APL interpreter

As an interesting sub-part of an interpreter -- just the Read part of the REPL -- I present my raw-mode line-oriented editor that I intend to use for my APL interpreter. (The Eval part has been posted ...
6
votes
2answers
66 views

An installer for shell scripts, written in pure sh

I wrote a tiny shell script that basically installs a script into your system by copying it to someplace like /usr/local/bin, chmodding it, and adding it to your ...
5
votes
2answers
64 views

Pseudoportable C script pattern - follow-up

See the initial/previous iteration. I have rewritten the script following the answer of @200_success. Now it looks like this: ...