Linux is a Free (libre), Open Source, Unix-like operating system.

learn more… | top users | synonyms

1
vote
1answer
31 views

Alert on partition growth

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
31 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 ...
3
votes
0answers
45 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
42 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
98 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
23 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
55 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
38 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 ...
-4
votes
1answer
38 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
57 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
90 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
27 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
296 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
166 views

Parsing /proc/net/sockstat

I have this very simple code which is used to parse values: ...
6
votes
1answer
124 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
47 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
135 views

Bash CGI Upload File

I'm using the following Bash CGI to upload a file: ...
1
vote
2answers
35 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
76 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
69 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. ...
10
votes
3answers
149 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
223 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 ...
12
votes
1answer
142 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
64 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
192 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
67 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
184 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
2k 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
351 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 ...
3
votes
1answer
95 views

Parsing arguments for cd command

This file manager has a code snippet that handles an argument of the "cd" console command. It converts the argument to a valid path, expands ~ and environment variables into the corresponding values: ...
6
votes
5answers
241 views

Mounting multiple partitions on a disk

Is it possible to improve the code of this bash script? ... or should I just use another language? (If so, which one would fit the best the situation, according to you?) Here is the code (simplified, ...
3
votes
2answers
447 views

Editing /etc/network/interfaces

I am trying to change static to dhcp in the /etc/network/interfaces file and vice versa ...
6
votes
1answer
2k views

Using /proc/stat to calculate CPU usage

Inspired by this question: To calculate the total CPU usage as a percentage I wrote the following bash script (as an answer) to calculate the CPU usage for a (configurable) period over all CPU cores ...
12
votes
2answers
2k views

To calculate the total CPU usage as a percentage

I have been developing the below method to calculate the CPU usage of a Linux system at a point in time, as a percentage of the total number of cores available in the system. ...
10
votes
2answers
338 views

Minimalistic rmdir

In my eyes most of the GNU stuff is bloated and doesn't really fit my view of how a Linux environment should look like. I have come up with my own minimalist implementation of the GNU Coreutils, but ...
4
votes
1answer
37 views

Script to fix audio level

I need to fix and maintain the master volume in PulseAudio (so that I don't blow up my speakers). E.g. call gfaaudio -v 25 to fix volume at 25%. Is there a cleaner ...
10
votes
2answers
381 views

Parsing of a (Linux) netlink hotplug uevent packet

The netlink service is used, among other things, to notify userspace about hotplug events (e.g. "a device has been connected"). These events come in the form of packets, which follow the following ...
3
votes
2answers
133 views

Group and send all files to filetype folder

I have around ~2M of files in one folder, which I need to manage. So, I want to separate them in groups by their filetypes. Example: filenames ...
10
votes
3answers
941 views

Parsing ARP cache in C

How can I make this better? ...
3
votes
1answer
255 views

Perl script to check disk usage

I'm looking for input on the code itself and formatting/style. This script parses the output of df -h on a Linux server and emails the user if the usage percentage ...
2
votes
0answers
90 views

Linux-based WiFi AP daemon [closed]

I've written this small Linux-based daemon to create a WiFi AP that should work across various distros like Ubuntu, Fedora, etc. I'm not a great expert in Python, nor do I know that the various ...
4
votes
1answer
64 views

Generic Makefile

I decided to setup a generic makefile to compile SFML programs, as I'm going to be making a bunch of small apps over the next few weeks playing around with it. I'm still new to writing makefiles ...
5
votes
2answers
3k 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 ...
5
votes
2answers
462 views

Benchmarking our LAMP servers with this php script

I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors: Disk I/O Database I/O (mysql) Database I/O (sqlite) The logic is as follows: ...
2
votes
1answer
90 views

Optimizing string replacement program that uses recursion

I have the following string replacement program for a string of size 256: I am replacing the string "\'" with the string &apos; Please suggest any modifications if needed or any ...
3
votes
1answer
871 views

Converting from std::wstring to std::string in Linux

I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question: Converting between ...
2
votes
1answer
38 views

IPtables for webserver with SSH

I've had a bit of help but I'm still a bit unsure. I have an nginx webserver with SSH only required. I wrote this rule set based on information I found on the internet: ...
4
votes
1answer
153 views

Is there a better way to copy into two different folders on a machine simultaneously?

I am trying to copy files from machineB and machineC into machineA as I am running my below ...
6
votes
1answer
123 views

Copying files as fast as possible

I am running my shell script on machineA which copies the files from machineB and machineC ...
3
votes
1answer
438 views

Script for obtaining images from an IP security camera

I am fairly new to Python and programming in general so I hope the code in this post is not too messy. I have the following code which I use for taking images from an IP security camera: ...