Operating System - HP-UX
1830400 Members
2765 Online
110002 Solutions
New Discussion

/usr/bin/which[7]:Syntax error at line 7: "(" is not expected

 
Kong Kian Chay
Regular Advisor

/usr/bin/which[7]:Syntax error at line 7: "(" is not expected

System: HP-UX 11.0, After reboot :--
#/usr/bin/which lp
--> above error messg

#ll /usr/bin/which
r-xr-xr-x 1 bin bin 661 Nov 7 1997 /usr/bin/which

Any suggestions to resolve above error?

Have tried:
* copy /usr/bin/which from another working system, same problem
* "diff" /usr/bin/which with another working system's, NO Difference.
7 REPLIES 7
Printaporn_1
Esteemed Contributor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

For me
#/usr/bin/which lp
/usr/bin/lp
#cksum /usr/bin/which
1271578485 661 /usr/bin/which
#cksum /usr/bin/lp
3622737874 49152 /usr/bin/lp

Does checksum output is same as mine ?
enjoy any little thing in my life
Kong Kian Chay
Regular Advisor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

Printaporn

* "cksum /usr/bin/which" produces the SAME cksum as yours :--
1271578485 661 /usr/bin/which

NOTE:
* Don't think there is anything wrong with the /usr/bin/which script --> read my "NOTE" in my 1st post.

Bill Hassell
Honored Contributor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

/usr/bin/which is a csh script. Start with a root login which uses the requisite POSIX shell and try this:

# type which

(type is an alias for whence -v, a much more useful command than which or whereis)

If: type which produces: "which is /usr/bin/which"

then try this:

# /usr/bin/which lp

If that works OK, then the previous command probably did not return: /usr/bin/which

The point is that the shell NOT run the command you expect unless $PATH and aliases are standard. type (and whence) will tell you exactly what the shell will run, something that which and whereis will not. Try:

# whereis history
# which history
# whence -v history

Once you know that /usr/bin/which is the command that is being run, the next is to see if something in the environment is overriding the shell interpreter line:

#! /usr/bin/csh

If this line is missing, then the current shell will be used to interpret the script. Thus, if you are running POSIX shell or ksh and the interpreter line is missing, you'll get the error listed in your subject line.

Perhaps someone has replaced /usr/bin/csh with /usr/bin/sh or /usr/bin/ksh? (some sysadmins would say this would be an improvement--I would never say that..)


Bill Hassell, sysadmin
Kong Kian Chay
Regular Advisor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

Bill

* You have nearly got it correct.
* I found that /usr/bin/csh has been overwritten.
* I ftp /usr/bin/csh from another working system, "cksum /usr/bin/csh" to compare. No difference.
* However, now the error mess has changed :

#type which (which is /usr/bin/which)
#/usr/bin/which lp
/usr/local/Cshrc: No such file or directory
#whereis history (history: )
#which history
/usr/local/Cshrc: No such file or directory
#whence -v history
history is an exported alias for fc -l

Any ideas, Bill ?
Kong Kian Chay
Regular Advisor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

Sorry, would like to add that I am login as "root".
Kong Kian Chay
Regular Advisor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

1 more info: /usr/bin/which 1st line is "#! /usr/bin/csh". It has same CKSUM value as another working system & it "diff" /usr/bin/which with another system produces nothing.
Kong Kian Chay
Regular Advisor

Re: /usr/bin/which[7]:Syntax error at line 7: "(" is not expected

I have found the problem :---
1) /usr/bin/csh has been overwritten
--> I have copied from another working system.

2) root's $HOME/.cshrc contains "source /usr/local/Cshrc".

After deleting root's $HOME/.cshrc, everything is now FINE.

The problem is now SOLVED.

Thank you everybody for your assistance, esp Bill who pointed me in the right direction.