I'm trying to read in a config file, and set the vars as env vars:
/etc/carma.conf :
informix_server=ol_p140
informix_dbname=proteus
informix_username=informix
informix_password=informix
mysql_dbname=proteus
/etc/carma.conf (END)
and the source snippet:
ifstream configFile;
char line[ 512 ];
configFile.open( "/etc/carma.conf", ios::nocreate );
if( !configFile )
{
cerr << "The Config file (/etc/carma.conf) is missing or not viewable!!\n";
}
while ( configFile.getline( line , 512 , '\n' ) )
{
if( putenv( line ) == -1 )
{
cerr << "Problem with putenv(line)\n";
}
}
cout << "CREATE DATABASE IF NOT EXISTS " << getenv("mysql_dbname"
<< ";\n";
cout << "USE " << getenv("mysql_dbname"
<< ";\n";
Now, every getenv call returns (null) and won't work. Any idea why?! This is frustrating
MWB. As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
/etc/carma.conf :
informix_server=ol_p140
informix_dbname=proteus
informix_username=informix
informix_password=informix
mysql_dbname=proteus
/etc/carma.conf (END)
and the source snippet:
ifstream configFile;
char line[ 512 ];
configFile.open( "/etc/carma.conf", ios::nocreate );
if( !configFile )
{
cerr << "The Config file (/etc/carma.conf) is missing or not viewable!!\n";
}
while ( configFile.getline( line , 512 , '\n' ) )
{
if( putenv( line ) == -1 )
{
cerr << "Problem with putenv(line)\n";
}
}
cout << "CREATE DATABASE IF NOT EXISTS " << getenv("mysql_dbname"
cout << "USE " << getenv("mysql_dbname"
Now, every getenv call returns (null) and won't work. Any idea why?! This is frustrating
MWB. As always, I hope that helped!
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.