syntax error in /etc/profile

Hi friends,

This is my first post to this forum so I will try to follow the accepted procedure.
I recently upgraded my lenovo t420 laptop to Tumbleweed and while everything seems ok I keep getting the following multiple errors whenever I do a zypper dup.

**/etc/profile: line 185: syntax error near unexpected token /usr/X11R6/bin' /etc/profile: line 185: /usr/X11R6/bin’

**I have searched the net high and low for an answer to this error but as I am pretty much a noob about bash scripts and /etc/profile I’m not sure what the error is. It dosen’t seem to negatively affect my system yet though I have noticed a few other errors like when I open a su terminal I get this at the prompt

**#
-bash: /etc/profile: line 185: syntax error near unexpected token /usr/X11R6/bin' -bash: /etc/profile: line 185: /usr/X11R6/bin’
**
Any help or advice would be greatly appreciated

regards Tim

I thought that I better supply the relevant section of /etc/profile…


# Make path more comfortable
#
# save current path setting, we might want to restore it
ORIG_PATH=$PATH
#
if test -z "$PROFILEREAD" ; then
PATH=/usr/local/bin:/usr/bin:/bin
if test "$HOME" != "/" ; then
for dir in $HOME/bin/$CPU $HOME/bin ; do
test -d $dir && PATH=$dir:$PATH
done
fi
if test "$UID" = 0 ; then
test -d /opt/kde3/sbin && PATH=/opt/kde3/sbin:$PATH
PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
fi
for dir in /usr/X11/bin
/usr/X11R6/bin
/var/lib/dosemu
/usr/games
/opt/bin
/opt/kde3/bin
/opt/kde2/bin
/opt/kde/bin
/usr/openwin/bin
/opt/cross/bin
do
test -d $dir && PATH=$PATH:$dir
done
unset dir
export PATH
fi

I hope that this helps
Tim

You seem to have lost the trailing ""s to continue the path.
From my Tumbleweed 20180122 /etc/profile:

    for dir in  /usr/X11/bin \
                /usr/X11R6/bin \
                /var/lib/dosemu \
                /usr/games \
                /opt/bin \
                /opt/kde3/bin \
                /opt/kde2/bin \
                /opt/kde/bin \
                /usr/openwin/bin \
                /opt/cross/bin
    do
        test -d $dir && PATH=$PATH:$dir
    done

Your line 185 is my line 173

I suspect that your problem might lie with:

I recently upgraded

Did you perform a distribution upgrade, as needed for Tumbleweed?
Something like:

 # zypper dup --from http://download.opensuse.org/tumbleweed/repo/non-oss/

Hi
Actually no i did a network dist upgrade but I originally tried from a usb.

How can I obtain an un-corrupted version of /etc/profile?

Using YaST > Software > Software Management and then searching for prifile with the item File list checked only, I find that /etc/profile is part of product aaa_base.

So you do a forced install of aaa_base. But it contains 73 files in total. I assume that you did not made any changes there (but OTOH your /etc/profile apparently is changed), but you have a quick look at that list before you overwrite all of them (I guess that they are all files that should not have been changed at all because the change that they are overwritten at a re-install/update is there).

It is a symptom of a bad upgrade (you did not say what you upgraded from).

 # zypper dup --from http://download.opensuse.org/tumbleweed/repo/non-oss/

should fix things. If it does not, please post the version from /etc/os-release and the output from

 > zypper lr -d -E

as well as any error messages.

/etc/profile is marked as config file though, so rpm will not replace it if it has been modified when updating the package (not even when using “zypper dup”… :wink: ).
So check whether you have an /etc/profile.rpmnew file and rename that to /etc/profile.

Or delete your /etc/profile and force a reinstallation of aaa_base to get the original file.

zypper in -f aaa_base

Thanks for your help guys, I appreciate it.

Thanks for your appreciation.

But we all want to know if it “worked”. :wink:

It seems to have worked because I’m no longer getting error messages when I login to the root terminal. The etc/profile looks very different now.
The real test will be when I do the next zypper dup because that’s where I was seeing all the syntax errors.
Oh and I dup’d from 42.3 Leap but it was pretty schetchy and didn’t really go as planned, the usb disc installation became a net install?
Many Thanks.

Make sure that you do not have any Leap repositories active.

When I migrated from Leap to Tumbleweed, I manually added the “tumbleweed/repo/oss/” and
“packman/suse/openSUSE_Tumbleweed/” (I have a Broadcom wireless chip that uses the kernel module from Packman) repositories and disabled all the others. Because the dup downloads are always pretty large, I use the “zypper dup -d” parameter to download everything before I start the dup proper.

Good Luck!

You guys might be interested that I found the cause of the corruption to /etc/profile.
I have been trying to get PacketTracer7 to work with Tumbleweed and after trying again I found the /etc/profile was damaged again.
At least I know how to repair it now. Oh well no PacketTracer in Tumbleweed for now, It’s annoying because it worked ok in Leap.
Regards

That’s not an openSUSE package, I suppose? (I can’t find it on software.opensuse.org)

In any case, that’s a “bug” in PackageTracer then.
It should not modify /etc/profile anyway IMHO, but rather add a custom file in /etc/profile.d/ if necessary.

Cisco – who have a well-earned reputation for ignoring good practice, at least as far as Posix systems are concerned.

That’s odd. Were they both PT-7.0 or 7.1? Btrfs and Snapshots are your friends when trying to install alienware.

I just downloaded Packagetracer-7.1 for a quick peek. It also appears to trample all over the QT5 libs. This stuff really should install in its own sandbox, jail or virtualisation.

Don’t do that. It would undo all vendor changes made to a system, f.e. to Packman. The proper way is definitely not to dup --from, but to ‘zypper dup’. Nothing else unless you want to apply a vendor change to some repo.

It’s not clear to me whether you edited /etc/profile to support your PacketTracer app.

If you did, that’s not what you’re supposed to do…
Following the comments in /etc/profile, you’re supposed to create a /etc/profile.local and place your customizations in that file.

An alternative is to create your customizations as a script, and place the script in /etc/profile.d/

It’s my understanding that whenever you do a zypper dup, /etc/profile is supposed to be over-written, erasing your edits.
Obviously, this would become a persistent problem in TW while only being a rare, occasional issue in LEAP.

TSU

I didn’t edit /etc/profile, PacketTracer 7 and 7.1(I tried both) did. I always use zypper dup only and /etc/profile wasn’t being overwritten.