Linux is a free (libre), open source, Unix-like operating system.

learn more… | top users | synonyms

6
votes
2answers
278 views

Locating a PID based on an IP address and port

I wrote a simple Python app that is given an IP address and port and the app then finds the PID listening on that IP:PORT. I would like to hear constructive criticism regarding the bellow code. ...
6
votes
0answers
50 views
+50

Backup Linux system to web

First I create a .tar of the root directory with all the file permissions saved and excluding all irrelevant directories (are these the right folders to be ...
3
votes
2answers
59 views

Assessment of client-server program source code

Can you assess source code of my client-server program? I would like to get an advice about design, code security etc. Thank you very much. The program does the following: Show files in ...
1
vote
0answers
13 views

Server framework

I decided to abstract out some of the code I use in personal projects into a library. In particular, it'd be used primarily for server-side programs, but I don't see any reason it wouldn't work fine ...
4
votes
2answers
86 views

Using sed regular expression to extract domain name from file

I'm learning regex with sed to extract the last field from file named "test". The method I'm trying gives desired output. Please suggest if this method Im trying is ...
7
votes
1answer
63 views

Adding support to Busybox vi for reading file from stdin

I am writing a patch for Busybox's implementation of vi, the classical command line code editor and predecessor of vim. It can ...
3
votes
1answer
42 views

Remove line numbers from shell history

I want to parse Linux history output and the commands parts only (without numbers): ...
7
votes
1answer
48 views

Detecting two keys pressed in quick succession

My computer has been having this issue where when I press a key, two key presses get registered. The goal of this program is to detect the time delta between the two keys so that I can set an ...
3
votes
1answer
26 views

Ruby script that deletes servers from Red Hat Satellite

This script uses the Red Hat Satellite v5.4 API to delete servers which are read in from a file. The servers are listed in the file by hostname but the Satellite API deletes servers by ID number. The ...
0
votes
0answers
43 views

Defining a char device driver protocol over uart at kernel level

My aim is to write a blocking char driver that return to the user space a complete protocol message from the kernel uart driver. Protocol description I'm fighting with a very bad protocol, called ...
2
votes
2answers
72 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
28 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 ...
4
votes
1answer
50 views

Remote control receiver for robot control

I have built an RC car and attached a Raspberry Pi to it - in order to control it, I wrote some Java code to listen to commands over the network and make the car move accordingly. ...
4
votes
2answers
47 views

Bash script to replace substrings in a file with strings

I am an editor of the Funtoo Linux wiki and was looking to create a shell script that would help to ease the updating of pages on the wiki that use old tags by replacing certain deprecated tags with ...
4
votes
2answers
52 views

Return from the parent process code or common code

In this program, the parent process creates a child process, then the child executes ls -l. The parent process waits for the child process to complete and then ...
4
votes
1answer
48 views

Restart Services Automatically

I have been working on a script that automatically checks on the state of 2 services that I require to be running 24/7 on a server that I manage. The script works as I need, but I would really like ...
4
votes
2answers
69 views

Installing and removing kernel module RPMs

First, the script checks to see if it is installing two kernel module packages or removing them by looking at the first parameter. If no parameter is provided it complains and exits. If installing, ...
3
votes
1answer
47 views

Append the first half of the first line of /etc/hosts to a conf file

I have to edit a config automatically before starting a service in a docker container (a storm supervisor), and I want to append something like this in ...
5
votes
1answer
168 views

Extracting emails from a file and writing them to another file

The code below works fine for me. Is there any way that I can improve this code more? Note: delimiter is single whitespace only for email address. getmail.py ...
3
votes
2answers
29 views

Changing filename and copying in bash

I wrote a script which changes names of last downloaded songs and copy them to music directory. Can it be written better? ...
3
votes
1answer
39 views

Ordered doubly-linked lock-free list

I'm implementing a lock-free ordered doubly-linked list based on heavily modified paper entitled Split-Ordered Lists: Lock-Free Extensible Hash Tables by ORI SHALEV. My main concern is correctness of ...
1
vote
1answer
35 views

Alert on partition growth [closed]

I have a script that alerts me via email when a partition grows past a defined threshold in one hour. My script is run from cron hourly. Everything seems fine for 99% of the time, but occasionally I ...
1
vote
0answers
50 views

Writing binary data to file in Linux

I'm trying to learn C++ and I would interested in how I could write better code. The code should be independent of the architecture it is running on. What I want to do is writing some binary data to ...
4
votes
0answers
150 views

Probe request capturing with Scapy

This is a probe request packet sniffer using python/scapy. It sniffs Dot11ProbeReq packets and display the ssid, MAC of device and manufacturer name from the probe requests. Can also output the data ...
4
votes
3answers
70 views

Bash script that checks if font is installed and installs it if necessary

I'm new to writing bash scripts and I was wondering if I could get someone's advice on a part of the script I'm working on. Intended purpose of code Check if a font is installed by using ...
4
votes
1answer
112 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 ...
2
votes
1answer
25 views

Bash script that checks for package dependencies and installs them if necessary

I'm new to Code Review and new to writing bash scripts as well. I was wondering if I could get someone's advice on a part of the script I'm working on. Intended purpose of code Check if a package ...
3
votes
1answer
64 views

Simple Linux pipeline

I've compiled a simple Linux pipeline and using my C style and modularization that I will use for my own operating system. Do you have something to say about this code (partly taken from SO)? For ...
1
vote
0answers
57 views

Local branch update script using Git and PHP

I'm using Git and PHP to create an update script which is sync local branch and the master. It checks about new updates, and if yes, it proceeds to the Git pull request and any response got from the ...
-5
votes
1answer
41 views

Reading temperatures from /sys

I have this code which is working fine but I would like to use Java 8 NIO in order to optimize the code performance. ...
3
votes
1answer
75 views

gcc installation script for Centos6.6

I have written this script to install gcc (here in version 4.9.2) on Centos6.6. I am only interested in C and C++ support. Please comment if this is any good and can I make it better before I get the ...
4
votes
1answer
97 views

Multipurpose command-line utility to manage a web application

I'm creating a command-line tool which is supposed to work on both Windows and Linux OS. It will be used to manage our application - start, stop, deploy etc. We have it in bash scripts now (and it ...
5
votes
1answer
36 views

Simple file locking wrapper command in C

A simple command that wraps another command, locking a file first. It is similar to flock, just simpler. ...
4
votes
2answers
366 views

Bash script to send emails when web server does not respond

I've made a simple bash script to check if a web server responds, and to send emails to a list of addresses if the website is down. Any suggestions as to how to improve it/ edge cases that I missed/ ...
3
votes
1answer
205 views

Parsing /proc/net/sockstat

I have this very simple code which is used to parse values: ...
6
votes
1answer
237 views

Fast Thread- and multiprocess-safe file operations in python under Linux

I'm trying to implement an alternative to python built-in open(), but safe for use in multi-threaded and multiprocessing environment. I'm using advisory locking, ...
4
votes
1answer
52 views

Simplifying a Makefile

I have a makefile like the one below and I am trying to simplify it. I know I should be assigning variables to cut down on repeated things but I am still confused as to how to properly simplify this ...
4
votes
2answers
268 views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...
1
vote
2answers
41 views

Repeatedly fetching a URL until the response contains “state: INIT”

I am working on a project in which I need to make a URL call to one of my servers from a bash shell script. http://hostname.domain.com:8080/beat After hitting the above URL, I will be getting ...
5
votes
3answers
90 views

Check disk space against a threshold

The below script is one I made to check the disk space on mounted partitions under Debian Wheezy. I tried adding a -d switch to force printing out the used data, ...
3
votes
2answers
88 views

Number of files with specific file size ranges

I am trying to write a script that will traverse through my directory and sub directory and list the number of files in a specific size. For example, 0kb-1kb: 3, 1kb-4kb:4, 4-16KB: 4, 16kb-64-kb:11. ...
12
votes
3answers
175 views

Making kexec reboots less painful

kexec is a way for a Linux kernel to directly boot another Linux kernel without going through the usual BIOS startup sequence, which can take several minutes on enterprise servers. The big problem ...
0
votes
1answer
332 views

Is this iptables firewall bash script good? [closed]

I'm learning to use iptables to implement it in my company software. The goal is either to prevent the major attacks and to have good speed transferring files (ssh and ftp). Can you help me to improve ...
13
votes
1answer
153 views

Calculating the harmonic average

In this program I was required to calculate the Harmonic Average using an assembly program with a C driver. Harmonic mean is define as: $$ \frac{n}{\dfrac{1}{x_1} + \dfrac{1}{x_2} + \cdots + ...
1
vote
1answer
90 views

Screen timeout/lock script

This is a script I made while having trouble with xautolock and dimming of the screen right before locking it. I would like some tips for making it a bit more robust and to know of any disadvantages ...
2
votes
1answer
271 views

Dovecot user add & delete bash script

I learn BASH scripting occasionally from time to time, now I am working on a simple bash script that serves to maintain dove-cot user database. The general purpose of the script is able to list, add ...
3
votes
3answers
70 views

Copy a directory from source to destination

I wrote a program that copies a directory from a source to a destination, similar to the cp utility. For this, I used the essential functions: ...
2
votes
0answers
221 views

Speeding up forwarding of Ethernet frames in Python ARP spoof

I've followed a few tutorials on ARP Spoofing with Python/scapy. They all suggest activating the OS IP Forwarding in Linux: ...
1
vote
3answers
3k views

Calculate CPU% by process from /proc/stat and /proc/<pid>/stat

We don't have the possibility to install modules like psutil on some boxes, thus I decided to write a simple script to calculate the CPU percentage by the given ...
3
votes
2answers
451 views

Checking percentage of free memory using top and awk

The following Awk code was created in order to verify if free memory from the top command is less than 20% of the total. I've noticed that I actually do not need the ...