/etc/profile error


 
Thread Tools Search this Thread
Operating Systems HP-UX /etc/profile error
# 1  
Old 03-23-2016
/etc/profile error

Hi

Please can you help me in solving the following error as I am logging in with any user, on my HP-UX system.
The error is /etc/profile[125]: Syntax error: `then' is not matched.
I have looked into /etc/profileline 125, but I dont see anything wrong.
# 2  
Old 03-23-2016
I looked in my crystal ball and did not see anything either.
Perhaps you can post the file? Please in [code] tags.
# 3  
Old 03-23-2016
I agree with MadeInGermany, but a not too wild guess would be that /etc/profile contains at least 124 lines and somewhere in the first 124 lines there is an if ... then with no matching fi.
# 4  
Old 03-24-2016
sorry, I have uploaded the file now:

Code:
vi /etc/profile
"/etc/profile" [Read only] 138 lines, 2793 characters
     1
     2  # @(#)B.11.31_LR
     3
     4  # Default (example of) system-wide profile file (/usr/bin/sh initialization).
     5  # This should be kept to the bare minimum every user needs.
     6
     7  # Ignore HUP, INT, QUIT now.
     8
     9          trap "" 1 2 3
    10
    11  # Set the default paths - Do NOT modify these.
    12  # Modify the variables through /etc/PATH and /etc/MANPATH
    13
    14          PATH=/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin
    15          MANPATH=/usr/share/man:/usr/contrib/man:/usr/local/man
    16
    17  # Insure PATH contains either /usr/bin or /sbin (if /usr/bin is not available).
    18
    19          if [ ! -d /usr/sbin ]
    20          then
    21                  PATH=$PATH:/sbin
    22
    23          else    if [ -r /etc/PATH ]
    24                  then
    25
    26                  # Insure that $PATH includes /usr/bin .  If /usr/bin is
    27                  # present in /etc/PATH then $PATH is set to the contents
    28                  # of /etc/PATH.  Otherwise, add the contents of /etc/PATH
    29                  # to the end of the default $PATH definition above.
    30
    31                          grep -q -e "^/usr/bin$" -e "^/usr/bin:" -e ":/usr/bin:"\
    32                                  -e ":/usr/bin$" /etc/PATH
    33                          if [ $? -eq 0 ]
    34                          then
    35                                  PATH=`cat /etc/PATH`
    36                          else
    37                                  PATH=$PATH:`cat /etc/PATH`
    38                          fi
    39                  fi
    40          fi
    41
    42          export PATH
    43
    44  # Set MANPATH to the contents of /etc/MANPATH, if it exists.
    45
    46          if [ -r /etc/MANPATH ]
    47          then
    48                  MANPATH=`cat /etc/MANPATH`
    49          fi
    50
    51          export MANPATH
    52
    53  # Set the TIMEZONE
    54
    55          if [ -r /etc/TIMEZONE ]
    56          then
    57             . /etc/TIMEZONE
    58          else
    59              TZ=MST7MDT               # change this for local time.
    60              export TZ
    61          fi
    62
    63  # Be sure that VUE does not invoke tty commands
    64
    65     if [ ! "$VUE" ]; then
    66
    67     # set term if it's not set
    68
    69          if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup"  \
    70               -o "$TERM" = "network" ]
    71          then
    72                  eval `ttytype -s -a`
    73          fi
    74
    75          export TERM
    76
    77     # set erase to ^H, if ERASE is not set
    78          if [ "$ERASE" = "" ]
    79          then
    80                  ERASE="^H"
    81                  export ERASE
    82          fi
    83          stty erase $ERASE
    84
    85     # Set up shell environment:
    86
    87          trap "echo logout" 0
    88
    89
    90     # This is to meet legal requirements...
    91
    92          cat /etc/copyright
    93
    94     # Message of the day
    95
    96          if [ -r /etc/motd ]
    97          then
    98                  cat /etc/motd
    99          fi
   100
   101     # Notify if there is mail
   102
   103          if [ -f /usr/bin/mail ]
   104          then
   105                  if mail -e
   106                  then    echo "You have mail."
   107                  fi
   108          fi
   109
   110     # Notify if there is news
   111
   112          if [ -f /usr/bin/news ]
   113          then news -n
   114          fi
   115
   116     # Change the backup tape
   117
   118          if [ -r /tmp/changetape ]
   119          then    echo "\007\nYou are the first to log in since backup:"
   120                  echo "Please change the backup tape.\n"
   121                  rm -f /tmp/changetape
   122          fi
   123
   124     fi                                           # if !VUE
   125  if [[ $(whoami) = root ]] ; then
   126     echo "User root logged in at $(date)" > /var/tmp/rlog.$$
   127     echo "" >> /var/tmp/rlog.$$
   128  #   who am i >> /var/tmp/rlog.$$
   129     who -T  >> /var/tmp/rlog.$$
   130     echo "" >> /var/tmp/rlog.$$
   131     ps -f >> /var/tmp/rlog.$$
   132     mailx -s "root login" fretagi@mcel.co.mz < /var/tmp/rlog.$$
   133     rm /var/tmp/rlog.$$
   134
   135  # Leave defaults in user environment.
   136
   137     trap 1 2 3
   138

---------- Post updated at 09:56 AM ---------- Previous update was at 09:46 AM ----------

I have now remove some code on it from line 126 to 133 and it looks fine

Last edited by fretagi; 03-24-2016 at 04:54 AM..
# 5  
Old 03-24-2016
And, as I said, there is in your code:
Code:
   125  if [[ $(whom) = root ]] ; then

with no matching fi. And, /etc/profile should be executable by a Bourne shell, but [[ expression ]] is not valid in a Bourne shell and is not valid in a 1988 version of ksh either (which, if present on your system should also use /etc/profile).

Removing from 126 on should leave you with the same problem. You need to remove line 125 as well!
This User Gave Thanks to Don Cragun For This Post:
# 6  
Old 03-24-2016
The header states it is HP-UX 11.31. In HP-UX 11.x the Bourne /bin/sh has been replaced by a Posix shell.
And this /bin/sh does know the [[ ]]. Also the ksh-88 knows it.
(While an old Bourne shell does not even know the $( ).)
These 2 Users Gave Thanks to MadeInGermany For This Post:
# 7  
Old 03-24-2016
Quote:
Originally Posted by MadeInGermany
The header states it is HP-UX 11.31. In HP-UX 11.x the Bourne /bin/sh has been replaced by a Posix shell.
And this /bin/sh does know the [[ ]]. Also the ksh-88 knows it.
(While an old Bourne shell does not even know the $( ).)
Thanks for pointing this out. I believe that the POSIX compliant /bin/sh on HP/UX is a version of the 1988 Korn shell. ksh88 does include [[ expression ]] but more expression primitives are available in ksh93 than were available in ksh88. The expression used in this case is valid in both ksh88 and ksh93. (But the if does still need a closing fi.)
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dot profile not found error

During batch processing the following error occurs and will stop the process, ~environment_name/.profile : not found. The error happens randomly. Any ideas? (6 Replies)
Discussion started by: dlhinpgh
6 Replies

2. Infrastructure Monitoring

trap in etc/profile and user .profile

Hello I really wonder what's trap in etc/profile and in each user .profile. I try to google for it but I think I have no luck. Mostly hit is SNMP traps which I think it is not the same thing. I want to know ... 1. What's a "trap 2 3" means and are there any other value I can set... (4 Replies)
Discussion started by: Smith
4 Replies

3. UNIX for Dummies Questions & Answers

difference between /etc/profile and .profile?

What is the difference between /etc/profile and .profile? (5 Replies)
Discussion started by: gehlnar
5 Replies

4. Shell Programming and Scripting

.profile file error on HPUX 11.11

Hi, I am working on HPUX 11.11i and 11.10 boxes. My default shell is ksh. I have the following entry in my profile file HOSTNAME=`uname -n` Every time I login to the server, this is the error I get: ${HOME:-.}/.profile: syntax error: `)' unexpected The line number shown... (1 Reply)
Discussion started by: Yomaanmean
1 Replies

5. UNIX for Dummies Questions & Answers

Where can I read about the difference between "..profile" and ".profile"

Hi I know from reading O Riley's Classic Shell Scripting' that the .profile file is " the shells configuration file" but I am unable to find a reference to what "..profile" means. I have searched on the net, Sams Teach Yourself Unix, Unix Visual Quickstart Guide and Linux in a Nutshell. I have... (2 Replies)
Discussion started by: zorrokan
2 Replies

6. SCO

Difference between .profile and .~/.profile

what is the difference between these two lines, if we use it in korn shell script: .profile .~/.profile (3 Replies)
Discussion started by: maneesh mehta
3 Replies

7. Post Here to Contact Site Administrators and Moderators

Error updating profile

I'm trying to update my profile with a temp e-mail address. This is a hotmail e-mail address and it wont allow it. The reason for this is I've changed my service with my ISP since I've moved :D and well I've gone form Cable to DSL :mad: Now my e-mail accounts are still there but I can't... (4 Replies)
Discussion started by: woofie
4 Replies

8. UNIX for Dummies Questions & Answers

changed .profile but didnt ./.profile, yet reflected changes

hi , i added ls -F to .profile. and i need to do ./.profile for the effect to take effect BUT i didnt and YET the next day when i came to work and log in, the changes took effect. i am on aix. please explain.. thanks (4 Replies)
Discussion started by: yls177
4 Replies
Login or Register to Ask a Question