Unix/Linux Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

/etc/profile error

HP-UX


Tags
solved

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-23-2016
fretagi fretagi is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 18 May 2017, 9:45 AM EDT
Posts: 390
Thanks: 95
Thanked 2 Times in 2 Posts
/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.
Sponsored Links
    #2  
Old Unix and Linux 03-23-2016
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 23 May 2017, 5:45 PM EDT
Location: Simplicity
Posts: 3,547
Thanks: 276
Thanked 1,181 Times in 1,069 Posts
I looked in my crystal ball and did not see anything either.
Perhaps you can post the file? Please in [code] tags.
Sponsored Links
    #3  
Old Unix and Linux 03-23-2016
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 23 May 2017, 8:08 PM EDT
Location: San Jose, CA, USA
Posts: 10,295
Thanks: 519
Thanked 3,583 Times in 3,051 Posts
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 Unix and Linux 03-24-2016
fretagi fretagi is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 18 May 2017, 9:45 AM EDT
Posts: 390
Thanks: 95
Thanked 2 Times in 2 Posts
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 03:54 AM..
Sponsored Links
    #5  
Old Unix and Linux 03-24-2016
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 23 May 2017, 8:08 PM EDT
Location: San Jose, CA, USA
Posts: 10,295
Thanks: 519
Thanked 3,583 Times in 3,051 Posts
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!
The Following User Says Thank You to Don Cragun For This Useful Post:
fretagi (03-24-2016)
Sponsored Links
    #6  
Old Unix and Linux 03-24-2016
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 23 May 2017, 5:45 PM EDT
Location: Simplicity
Posts: 3,547
Thanks: 276
Thanked 1,181 Times in 1,069 Posts
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 $( ).)
The Following 2 Users Say Thank You to MadeInGermany For This Useful Post:
Don Cragun (03-24-2016), hicksd8 (03-24-2016)
Sponsored Links
    #7  
Old Unix and Linux 03-24-2016
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 23 May 2017, 8:08 PM EDT
Location: San Jose, CA, USA
Posts: 10,295
Thanks: 519
Thanked 3,583 Times in 3,051 Posts
Quote:
Originally Posted by MadeInGermany View Post
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.)
The Following User Says Thank You to Don Cragun For This Useful Post:
hicksd8 (03-24-2016)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Dot profile not found error dlhinpgh Shell Programming and Scripting 6 04-07-2010 07:08 PM
.profile file error on HPUX 11.11 Yomaanmean Shell Programming and Scripting 1 12-29-2008 11:43 AM
Error updating profile woofie Post Here to Contact Site Administrators and Moderators 4 01-18-2005 04:20 PM



All times are GMT -4. The time now is 08:39 PM.