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

learn more… | top users | synonyms

3
votes
1answer
44 views

Service to keep variables in memory

I'm a beginner C programmer. I want to write a program with the following characteristics: The program is essentially a 'daemon' or a 'service' that sits in the background doing nothing except ...
1
vote
0answers
59 views

Touchscreen Right Click

I have built a small script that provides touch screen right click context menu with long touch press in my ELAN touchscreen. There is no need to remove your finger in order context menu to pop up. ...
3
votes
0answers
44 views

Iterating through an array once [closed]

I am tasked with writing a script that analyzes code and attaches a comment with #Loopn or #Selection n that corresponds with ...
2
votes
1answer
104 views

Keep NumLock always on in C++ on Linux

I intend to replace my bash script executing these two very same commands infinitely, for the bash script seems rather ineffective: /usr/bin/numlockx on ...
3
votes
0answers
34 views

Linux performance using multi-threads (vs one thread) and ssh message

My server receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however... When I am doing the ...
3
votes
1answer
63 views

Countdown AppIndicator

I've decided to translate an old Unity AppIndicator I had written in C to Ruby, so I can practice coding with it (got a little bored with the completely beginner lessons I've been following, which I'...
3
votes
0answers
24 views

msysGit to Unix sockets

I wrote this small script to help porting msysGit sockets to WSL ("Bash for Windows"). I'm not a big Python programmer so any feedback would be well appreciated. By the way, I made it a public Gist ...
3
votes
1answer
48 views

Waiting for input with timeout

When my program begins, I want to allow the user to hit a key to enter debug mode for one of the modules. Many of the solutions (involving alarm(), in particular) ...
1
vote
1answer
73 views

Simple Linux upgrade script in Bash revision 2

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
6
votes
1answer
82 views

Simple Linux upgrade script in Bash

As I will be deploying this script on multiple machines with the very same system Linux Mint 18 with rather same configuration, I would like to be semi-sure I won't screw things up much. This little ...
4
votes
2answers
61 views

Optimize text search in files with Bash

I would like to get some performance improvement suggestions to a simple project I made using Bash in Linux. The target is to read all the *.desktop files, and ...
8
votes
3answers
249 views

Removing multiple slashes from path

I have been trying to write a sample code block to remove multiple backward or forward slashes from a path (e.g. //a//b should be ...
2
votes
2answers
51 views

Passing help options to a bash script

I used this code to give -h(help) options to my bash script. It's working fine and I wanted to get the code reviewed. ...
10
votes
2answers
162 views

mini-(Docker)-shell

I was given an assignment to write a mini-shell: To write your own shell, you will need to start with a C program that will prompt the user for input and accept in a number of arguments from a ...
4
votes
2answers
39 views

Parse a substring out of string, allocate memory accordingly

I have written the following code in order to: Find begin and end of FTP user and password from a given URL (ftp://[user[:password]@]host[:port]/url-path) Allocate ...
3
votes
2answers
61 views

Finding duplicate files using md5sum Unix command

This is an exercise from Think Python: How to Think Like a Computer Scientist Here's its description: In a large collection of MP3 files, there may be more than one copy of the same song, stored ...
1
vote
0answers
17 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: ...
5
votes
1answer
45 views

Bash function that allows running user aliases with sudo on Ubuntu

I wrote this little Bash function to replace my sudo command. It checks whether I have an alias for the given command and runs the aliased command instead of the ...
1
vote
1answer
25 views

Parse child value from XML using ezxml

I'm parsing an XML file and searching for a child value. As I'm familiar with this XML file structure, I know that the final value is a child of a child, and so I wrote the following code section: <...
2
votes
2answers
34 views

High CPU utilisation for Logs Manager shell script

I have written a shell script to manage the tcpdump pcap logs and syslog files in my Linux board, so as to maintain the disk usage to maximum of 70%. The script checks for the disk usage every ...
6
votes
2answers
86 views

CPU core temperature Unity indicator

Project now on Github: https://github.com/IanCaio/TempI I just finished a working version of a small Unity indicator in C, that is supposed to take the output of the application "sensors" (...
1
vote
1answer
18 views

Pausing script while waiting for Docker container and printing updates

I'm looking to improve it in brevity, readability, and simplicity. Basically, I'm just looking for a more elegant solution. What improvements can I make? ...
0
votes
1answer
60 views

Basic GNU/Linux C++ serial I/O class

I have wrote a small C++ class that provides some basic serial I/O functionality (it uses the standard GNU/Linux API). At this stage is working fine, before adding new functionality I want to get ...
1
vote
2answers
55 views

Iterating over a range of dates in a shell script

I have been working on a script that can be used to automatically pull the batch ids that were processed 4 days ago and which need to be processed tomorrow on the server. The batch IDs from 3 days ago ...
2
votes
0answers
48 views

Multithreaded C program to calculate CPU usage of cgroups

I am writing a program in an environment that makes use of cgroups to identify and group processes together. I want to parse the CPU utilization of each cgroup by sampling ...
4
votes
2answers
84 views

Simple program to read memory usage by PID in Linux

I just learn a little bit about C Programming and try to create a modular program so I created simple program to read memory usage by pid(s) in Linux. ...
3
votes
1answer
59 views

Automation of application utilities on Linux

I am working on a project to automate utilities of our application on Linux. The utilities are basically chunks of programs with specific options for specific tasks. They are run like UNIX commands. ...
1
vote
2answers
77 views

Hexdump utility in x86 NASM assembly

It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after ...
6
votes
1answer
44 views

Extracting Linux configuration information using Bash and Perl

For few days I'm thinking about making my code faster and using less CPU. This code is a statusbar that runs in a loop. I'm asking because there's a lot of perl and I'm wondering if it could be done ...
4
votes
1answer
33 views

Yum Notification Script

This is a Bash script I wrote to email me when updates are available for my server. I'm new to bash programming, so I don't know if I've done this well. ...
5
votes
1answer
16 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 ...
14
votes
2answers
1k views

Tetris in C, in 200 lines

I aimed at making fully functional (real) Tetris, in the shortest way possible in C. The result is a terminal game for Linux, that uses ncurses. I made it for my friend, who wanted to play it on his ...
3
votes
1answer
53 views

File shredder in x86 NASM Assembly

This is a file shredder utility that runs on Linux. It writes random bytes over the file contents, repeating this 48 times and calling sys_fsync after each pass to ...
5
votes
1answer
36 views

Program to print all evironment variables

I'm learning x86 assembly on Linux and this is the first program I wrote, so I'm looking for all kinds of ways to improve it. ...
0
votes
0answers
28 views

Check the battery's charge level and emit an alert on low/high value

The following script check constantly the battery's charge level of the user's laptop via the acpi command. When such level reach a low/high value, the script will ...
5
votes
1answer
58 views

Brightness Web Server

This is the first real program I've written in Go so have at it! I wrote it because I use a tiling window manager that doesn't have any brightness control functionality (at least not that I know of). ...
4
votes
1answer
97 views

Raspberry Pi headless server using bash and USB automounting

Revised from: Bash scripts and udev rules to handle USB auto mounting / unmounting Tested: Uses USB insert/remove to control a headless Raspberry Pi 3 with Raspian Jessie Lite Changes: Implement ...
2
votes
1answer
88 views

Bash scripts and udev rules to handle USB auto mounting / unmounting

Very new to Raspberry Pi and bash, but working on a headless server that will run a streaming app from USB audio card. The plan is to take a USB card with settings file, and when inserted, the usb ...
5
votes
3answers
1k views

Snake game in C for Linux console

Please help me improve this code. Move snake using : a w s d. (My compiler doesn't support initialization of index variables inside loops, so please ignore this part) ...
8
votes
1answer
107 views

Baby-sitting bash script using DVD drive

This is the script I wrote to make an automated POC baby-sitter in 5 lines. I first found this on a GIF or meme site and thought of making a POC script that does the same. ...
8
votes
2answers
163 views

Thread to send heartbeat UDP packets

This C code will run on an embedded machine with a Linux OS. It should create data packets (ASCII) to repeatedly be sent to a UDP server. Just to give an overview about what functions should do: <...
5
votes
2answers
94 views

Thread synchronization with mutex

This program prints odd numbers by thread1 and even numbers by thread2 sequentially. Can this code be optimized or made more ...
1
vote
1answer
69 views
5
votes
1answer
50 views

Bash script for xrandr modification

Simply, I call the script (brightness.sh) and pass a three character value as an argument. I've got commands to strip individual numbers for math processes, and then the final commands to apply the ...
3
votes
1answer
76 views

Template for PHP service (/etc/init.d) script

I wanted a template for a service script that is versatile and easily configurable. Along with producing similar outputs to the SSH and Samba daemons, I request the code to be as clean, simple and ...
4
votes
1answer
45 views

Simple shell script to backup to Amazon over iSCSI

The script works but I know that it can be improved. Please note that my scripting skills are very basic :) (as it can be seen in my Frankenstein script – I took bits and pieces of the code from ...
4
votes
1answer
65 views

Bash script to determine a distro, update, upgrade and install the apps I use

This is my first bash script. I am trying to learn scripting and needed an idea. This is the first idea I came up with. When I used to distro hop I had to reinstall everything. This helped me out once ...
4
votes
1answer
91 views

Watch log dir for new file, automatically tail to slack

We have a process that outputs to log files in the format /var/log/xxx/YYYY_MM_DD.log - the file name is chosen programmatically and is not rotated using logrotate ...
0
votes
0answers
55 views

Resolving the path to a Bash script

I wrote a function to resolve the full path to the current Bash script, and I'm wondering if it's SOLID: ...
-1
votes
1answer
70 views

Measuring execution time of a simple operation

The purpose of the following code is to measure the execution time of a simple operation (1+1) and of a call to a function who does nothing (foo). The code ...