LAMP How To – Open Source At Work

Only Passion Matters

Entries for August, 2009

bash: passing output from one program to another

sometimes you want to be able to pass output from one program to another, say from bash to php. There is a neat trick to do it. In php, we execute the bash script restartapache.
<?php
$command=”/usr/local/bin/restartapache {$_GET['server']}”;
exec($command, $output); foreach ($output as $v)
{ echo “$v <br/>”; }
?>
then in the bash, we write the output to a [...]

selinux: samba and nfs

I find “man samba_selinux” really well documented. All the common problems associate with samba selinux can be found there.

find all hidden files in a directory and delete

This turns out to be much slightly tricky. I came up with this solution

find . -type f | grep ‘\/\.[^.]*’ | xargs rm -rf

mass files with illlegal names in linux

Windows are notorious for having files that are named with illegal characters like ?, & spacing…etc. To mass rename them, remember to use quotations in the mv command. eg

for i in *; do mv “$i” newfile_”$i”; done;

It took me along time to figure out that the error lies in the mv command and not the [...]

extract rpm files

This is useful if we need to get certain source libraries from the rpms.

rpm2cpio php-5.1.4-1.rpm | cpio -idmv

You should see a tar file after extraction. untar it.