Archive for 'Shell'
Ever want to immediatly serve content from a specific directory over HTTP, but didn’t want to bother messing with httpd.conf or other webserver configiurations?
If you’ve got Python installed, this is a snap. Execute python with the SimpleHTTPServer module, using port 8080 so there isn’t a need to elevate privs to root.
$ python -m SimpleHTTPServer 8080
Serving [...]
I was reading through Jim Perrin’s CentOS hardening article, and saw one super interesting use of read-only bourne shell variables. If you have users that are frequently logging in and staying idle for days and or weeks, you can add a readonly TMOUT variable to /etc/profile:
$ echo “readonly TMOUT=3600″ >> /etc/profile
The TMOUT variable controls the [...]
I have been working on a shell script that manages lxc-containers, and came across a use case last where it is possible for two yum processes to interfere with each other. To ensure that only one yum process is run at a single point in time, I implemented file based locks using flock(1). Flock makes [...]
The Bourne shell provides here documents to allow block of data to be passed to a process through STDIN. The typical format for a here document is something similar to this:
command <<ARBITRARY_TAG
data to pass 1
data to pass 2
ARBITRARY_TAG
This will send the data between the ARBITRARY_TAG statements to the standard input of the process. In order [...]
While debugging an issue with one of my scripts, I wanted to abort execution and exit when a non-zero return code occurred. I recalled reading about a bash flag that provided this behaviour, and after a few minutes of reading through bash(1) I came across the following set option:
“-e Exit [...]
While crafting an install script a week or two ago, I came across an annoying issue with the Solaris sed utility. When I tried to substitute the string ‘, ‘ with a newline, I got this:
$ grep foo gemlist | sed -e ’s/foo.*(//’ -e ’s/)//’ -e ’s/, /\n/g’
2.4n2.3n2.2n2.1
But when I ran the same sustitution with [...]