1756630 Members
2603 Online
108849 Solutions
New Discussion юеВ

rc.config Syntax error

 
Mynor Aguilar
Valued Contributor

rc.config Syntax error

Recently, I had some issues regarding my server's hostname, whenever I restarted the system it changed back to "unknown". After reading some other thread, I found my problem in the rc.config file
I tried to manually started it:

root:/etc #ll rc.config
-r--r--r-- 1 root sys 636 Apr 11 00:34 rc.config
root:/etc #./rc.config
sh: ./rc.config: Execute permission denied.

I changed permissions to allow execution to everybody

root:/etc #chmod 777 rc.config
root:/etc #./rc.config
./rc.config[13]: Syntax error at line 3 : `(' is not expected.

now i get this weird error saying that there's a syntax error on the rc.config file, i have already checked and replace this file with another one (the one on /usr/newconfig/etc/rc.config) but still got the same problem.

just by looking at the file I can't find anything wrong with it, can somebody help me find the source of the problem (see rc.config attachment)
9 REPLIES 9
Steven Schweda
Honored Contributor

Re: rc.config Syntax error

Without a "#!" first line, this script
(script fragment, actually) does not specify
the shell to be used to process it. With a
plain "#", you might be getting a C shell, or
who knows what?

Script fragments like this are normally fed
to the shell of your choice, for example:

sh ./rc.config

And for that, you don't need execute
permission.

That may not make your script (fragment) work
properly, but it should get it executed.
Anshumali
Esteemed Contributor

Re: rc.config Syntax error

cd /etc
sh rc.config
you may try entering
echo Done
in last of the your rc.config to check for execution.
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
Jollyjet
Valued Contributor

Re: rc.config Syntax error

Change your permission back to read and execute via sh
Dennis Handly
Acclaimed Contributor

Re: rc.config Syntax error

rc.config is meant to be sourced:
# . ./rc.config

If you replaced by the one it newconfig, you should be fine. This file should not be changed, only the files under /etc/rc.config.d/.

Note line 13 is sourcing files in rc.config.d/ and it could be a file there that has that "(" syntax error.

I assume you know, you can't have any left over files in that directory??

You could also add "set -x" to rc.config to see which file in rc.config.d/ has the problem, then remove that -x.
SANTOSH S. MHASKAR
Trusted Contributor

Re: rc.config Syntax error

Hi,

How do u know that there is problem with ur
/etc/rc.config ?
If u r experienceing problem with hostname then
it cound be some configuration errors (HOSTNAME)
in the file /etc/rc.config.d/netconf.

Check this and also restore permissions of
/etc/rc.config.


-Santosh
SANTOSH S. MHASKAR
Trusted Contributor

Re: rc.config Syntax error

Hi,

/etc/rc.config doesnot require execute permissions.
This file is executed by init and executed in the
same shell
eg.
# . /etc/rc.config

will execute the file in same shell so that all
the env. variables are available in the present
shell.

Also as u have told below

root:/etc #./rc.config
./rc.config[13]: Syntax error at line 3 : `(' is not expected.

Line no. 13 is
if [ -f $CFG_FILE -a "$fname" != "core" -a "${fname##*[.,~\#]}" = "$fname" ]

nowhere '(' sign.

So I suggest u to verify /etc/rc.config.d/netconf
and set HOSTNAME parameter in that file
and reboot the machine. If u don't want to
reboot u can temporarily set hostname as

# hostname

but it will vanish after a reboot, so
set HOSTNAME in /etc/rc.config.d/netconf

Ralph Grothe
Honored Contributor

Re: rc.config Syntax error

Please, revoke the write and execute bits from rc.config (chmod 0444 /etc/rc.config).
As others already have replied this file isn't meant to be executed but to be sourced.
As you can easiliy verify the sourcing of rc.config actually happens here:

# grep -n rc\.config /sbin/rc
58:# If /etc/rc.config contains default information (first boot),
66:if [ -f /etc/rc.config ]; then
67: . /etc/rc.config
76: echo "\nWARNING: /etc/rc.config does not exist"


rc.config isn't meant to be tampered with at all.
So it was a good decision to copy the original from newconfig back in place.

Your syntax error most likely results from any of your files in /etc/rc.config.d

What you could do to possibly identify the culprit may be this:

# cd /etc/rc.config.d
# echo *|xargs -n1 sh -n 2>&1|grep -v permission\ denied



Madness, thy name is system administration
SANTOSH S. MHASKAR
Trusted Contributor

Re: rc.config Syntax error

Hi,

/etc/rc.config doesnot require execute permissions.
This file is executed by init and executed in the
same shell
eg.
# . /etc/rc.config

will execute the file in same shell so that all
the env. variables are available in the present
shell.

Also as u have told below

root:/etc #./rc.config
./rc.config[13]: Syntax error at line 3 : `(' is not expected.

Line no. 13 is
if [ -f $CFG_FILE -a "$fname" != "core" -a "${fname##*[.,~\#]}" = "$fname" ]

nowhere '(' sign.

So I suggest u to verify /etc/rc.config.d/netconf
and set HOSTNAME parameter in that file
and reboot the machine. If u don't want to
reboot u can temporarily set hostname as

# hostname

but it will vanish after a reboot, so
set HOSTNAME in /etc/rc.config.d/netconf
if u want to set it parmenant.
Mynor Aguilar
Valued Contributor

Re: rc.config Syntax error

thanks for all your replies, I'm currently out of office and will let you know the status of this as soon as I can.
Thanks