Robert Moskowitz
2017-Feb-21 15:50 UTC
[CentOS] Problems with my simple write conf files method
I have been creating conf files and similar with the following method that I picked up (I think from psotfix docs): cat <<EOF>>/etc/aliases || exit 1 root: youremail EOF See: http://medon.htt-consult.com/Centos7-armv7.html But with postfixadmin I stumbled onto a problem. The following: cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 <?php $CONF['database_type'] = 'mysqli'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'xyz'; $CONF['database_name'] = 'postfix'; $CONF['configured'] = true; ?> EOF produces: cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 <?php ['database_type'] = 'mysqli'; ['database_user'] = 'postfix'; ['database_password'] = 'xyz'; ['database_name'] = 'postfix'; ['configured'] = true; ?> That is the '$CONF' gets processed. What can I do to avoid this (and any other 'gotchas') or can someone provide an alternative? thanks
I have never used this method per se, but in general in any script if you want to preserve the $ (dollar sign) or variable name you must use a backslash to preserve it. For example change your $CONF to \$CONF.? The $CONF should then be printed into your conf file. KM From: Robert Moskowitz <rgm at htt-consult.com> To: centos at centos.org Sent: Tuesday, February 21, 2017 10:50 AM Subject: [CentOS] Problems with my simple write conf files method I have been creating conf files and similar with the following method that I picked up (I think from psotfix docs): cat <<EOF>>/etc/aliases || exit 1 root: youremail EOF See: http://medon.htt-consult.com/Centos7-armv7.html But with postfixadmin I stumbled onto a problem.? The following: cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 <?php $CONF['database_type'] = 'mysqli'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'xyz'; $CONF['database_name'] = 'postfix'; $CONF['configured'] = true; ?> EOF produces: cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 <?php ['database_type'] = 'mysqli'; ['database_user'] = 'postfix'; ['database_password'] = 'xyz'; ['database_name'] = 'postfix'; ['configured'] = true; ?> That is the '$CONF' gets processed. What can I do to avoid this (and any other 'gotchas') or can someone provide an alternative? thanks _______________________________________________ CentOS mailing list CentOS at centos.org https://lists.centos.org/mailman/listinfo/centos
Robert Moskowitz
2017-Feb-21 16:40 UTC
[CentOS] Problems with my simple write conf files method
On 02/21/2017 11:03 AM, KM wrote:> I have never used this method per se, but in general in any script if you want to preserve the $ (dollar sign) or variable name you must use a backslash to preserve it. For example change your $CONF to \$CONF. The $CONF should then be printed into your conf file.Thanks that worked.> KM > > From: Robert Moskowitz <rgm at htt-consult.com> > To: centos at centos.org > Sent: Tuesday, February 21, 2017 10:50 AM > Subject: [CentOS] Problems with my simple write conf files method > > I have been creating conf files and similar with the following method > that I picked up (I think from psotfix docs): > > cat <<EOF>>/etc/aliases || exit 1 > root: youremail > EOF > > See: http://medon.htt-consult.com/Centos7-armv7.html > > But with postfixadmin I stumbled onto a problem. The following: > > cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 > <?php > $CONF['database_type'] = 'mysqli'; > $CONF['database_user'] = 'postfix'; > $CONF['database_password'] = 'xyz'; > $CONF['database_name'] = 'postfix'; > > $CONF['configured'] = true; > ?> > EOF > > produces: > > cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 > <?php > ['database_type'] = 'mysqli'; > ['database_user'] = 'postfix'; > ['database_password'] = 'xyz'; > ['database_name'] = 'postfix'; > > ['configured'] = true; > ?> > > That is the '$CONF' gets processed. > > What can I do to avoid this (and any other 'gotchas') or can someone > provide an alternative? > > thanks > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos > > > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos
Ian Mortimer
2017-Feb-22 02:27 UTC
[CentOS] Problems with my simple write conf files method
On Tue, 2017-02-21 at 10:50 -0500, Robert Moskowitz wrote:> cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 > <?php > $CONF['database_type'] = 'mysqli'; > $CONF['database_user'] = 'postfix'; > $CONF['database_password'] = 'xyz'; > $CONF['database_name'] = 'postfix'; > > $CONF['configured'] = true; > ?> > EOFKMs method of escaping every $ in the here document works but a simpler method is to escape the EOF. That tells the shell not to do variable expansion in the document: cat <<\EOF>/usr/share/postfixadmin/config.local.php || exit 1 -- Ian
Robert Moskowitz
2017-Feb-22 13:23 UTC
[CentOS] Problems with my simple write conf files method
On 02/21/2017 09:27 PM, Ian Mortimer wrote:> On Tue, 2017-02-21 at 10:50 -0500, Robert Moskowitz wrote: > >> cat <<EOF>/usr/share/postfixadmin/config.local.php || exit 1 >> <?php >> $CONF['database_type'] = 'mysqli'; >> $CONF['database_user'] = 'postfix'; >> $CONF['database_password'] = 'xyz'; >> $CONF['database_name'] = 'postfix'; >> >> $CONF['configured'] = true; >> ?> >> EOF > KMs method of escaping every $ in the here document works but a simpler > method is to escape the EOF. That tells the shell not to do variable > expansion in the document: > > cat <<\EOF>/usr/share/postfixadmin/config.local.php || exit 1Thank you. I actually had problems with changes to /etc/postfix/master.cf where I have things like ${sender} that do not work as \${sender}. So mass changes of $ to \$ did not always work. :) Do I end with 'EOF' or \EOF'?
Maybe Matching Threads
- Problems with my simple write conf files method
- Problems with my simple write conf files method
- Problems with my simple write conf files method
- Centos 7 with Postfixadmin, what provides php5-mysql
- How we can create two database Using same credetial using Puppet