Skip to content
  • Page 1 of 2
  • 1
  • 2
  • >

Tag: bash

Making a bash script terminate when a command returns an error

#!/bin/bash -e trap "echo ERROR HANDLING HERE." ERR echo "Starting" asdfasdf echo "End" Read More »

Making a shell-script run with setuid root

If you want to run a process with root privileges that you can invoke as a less unprivileged user, you can make the program setuid root. This can be very useful, for example, when you want a PHP or CGI script to call a backup process, or to create a new site or irrevocably delete you whole system. The latter example points to a serious security problem: if anyone can figure out a way to make your program do something you don't want, you're screwed, because you just gave them root privileges to wreak maximum havoc. That's why, normally, scripts (anything executed by an interpreter by the kernel because of a shebang) won't get elevated privileges when you set their setuid bit. Read More »

Remove appending slash from a path using Sed

Here's how you can remove the appending slash from a path using sed, the stream editor: Read More »

Bash script template

A template bash script, for when you need something overengineerd that works. Read More »

Bash parameter parsing

Here is a code snippet I use for parameter parsing: dohelp() { echo "Example script" echo "" Read More »

Preventing syntax errors with old shell scripts

I was trying to install Unreal Tournament GOTY on one of my Linux machines. I downloaded and ran the script ut-install-436-GOTY.run but I got this error: Read More »

Replacing the full contents of a Subversion working (sub)dir

The annoyances that I suffered earlier today during the upgrade of a WordPress plugin made me turn to my favorite text-editor to create a simple script, svn-replace-dir: Read More »

My custom Linux environment

On every machine that I install, I need a custom environment. At the very basic, I need screen and bash customizations. I will attempt to keep this blog post up-to-date with my most recent config. Read More »

Bash script for sending SMS using Mollie

I signed up for a Mollie account so that I can send SMS's from my machines. To do that, I needed a bash script, so I wrote one: Read More »

Bash quoting

I'm always confused by bash's quoting. I hope to put all my quote wisdom in this post and invoke other's quote wisdom in the comments. I'll give some examples of what I mean. Read More »