Archive for December, 2007

sudo: sorry, you must have a tty to run sudo

Sunday, December 30th, 2007

if you are trying to run a command via sudo and encounter the following error:

sudo: sorry, you must have a tty to run sudo

then you can comment out the following parameter in the /etc/sudoers

#Defaults requiretty

Parsing a Config File in PHP

Thursday, December 13th, 2007

This is a sample code to parse a config file in PHP

$mosConfig_CONFIG_IDE=Y
$mosConfig_HOST=localhost


while (!feof($fp)) {
$line = trim(fgets($fp));
if (ereg('\$mosConfig_', $line)) {
$line = ereg_replace ('\$mosConfig_',"",$line);
$pieces = explode("=", $line);
$option = trim($pieces[0]);
$value = trim($pieces[1]);
$value = ereg_replace ("^\'","",$value);
$value = ereg_replace ("\'\;$","",$value);
$config_values[$option] = $value;
}
}
fclose($fp);