- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- which command error, need help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 02:09 AM
тАО10-04-2010 02:09 AM
prompt@localhost>which
which[7]: Syntax error at line 7 : `(' is not expected.
I don't why, but already looked into other HP-UX servers with working "which" commands but the script is just the same.
#! /usr/bin/csh
# @(#) $Revision: 72.1 $
#
# which : tells you which program you get
#
set noglob
foreach arg ( $argv )
set alius = `alias $arg`
switch ( $#alius )
case 0 :
breaksw
case 1 :
set arg = $alius[1]
breaksw
default :
echo ${arg}: " " aliased to $alius
continue
endsw
unset found
if ( $arg:h != $arg:t ) then
if ( -e $arg ) then
echo $arg
else
echo $arg not found
endif
continue
else
foreach i ( $path )
if ( -x $i/$arg && ! -d $i/$arg ) then
echo $i/$arg
set found
break
endif
end
endif
if ( ! $?found ) then
echo no $arg in $path
endif
end
What seems to be the problem in here and how can i fix it? Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 02:34 AM
тАО10-04-2010 02:34 AM
SolutionTry this to confirm:
$ sh /usr/bin/which
$ csh /usr/bin/which
Can you check that your csh has not changed (or replaced by another thing).
What is the result of:
$ what /usr/bin/csh
Regards,
Mounaam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 03:12 AM
тАО10-04-2010 03:12 AM
Re: which command error, need help
# sh /usr/bin/which
/usr/bin/which[7]: Syntax error at line 7 : `(' is not expected.
# csh /usr/bin/which
sh: csh: Execute permission denied.
# what /usr/bin/csh
/usr/bin/csh:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 03:43 AM
тАО10-04-2010 03:43 AM
Re: which command error, need help
> sh: csh: Execute permission denied.
It looks like you don't have execute permissions. This should look like:
# -r-xr-xr-x 1 bin bin 654 Feb 15 2007 /usr/bin/which
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:05 AM
тАО10-04-2010 04:05 AM
Re: which command error, need help
# ls -l /usr/bin/which
-r-xr-xr-x 1 bin bin 654 Nov 14 2000 /usr/bin/which
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:07 AM
тАО10-04-2010 04:07 AM
Re: which command error, need help
And besides, you can check these also:
# file /usr/bin/which
/usr/bin/which: commands text
# what /usr/bin/which
/usr/bin/which:
B.11.11_LR
# echo $0
/sbin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:12 AM
тАО10-04-2010 04:12 AM
Re: which command error, need help
Any reason you are using the scummy C shell or one if its utilities?
The real shell has "whence".
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:38 AM
тАО10-04-2010 04:38 AM
Re: which command error, need help
Check your's, Dennis. I think you'll find that that is the way HP provided it to us: with the scummy C shell!
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:46 AM
тАО10-04-2010 04:46 AM
Re: which command error, need help
And that's why you don't use which(1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 04:55 PM
тАО10-04-2010 04:55 PM
Re: which command error, need help
i do have execute permission for which
>ls -l /usr/bin/which
-r-xr-xr-x 1 bin bin 664 Oct 4 18:04 /usr/bin/which
>csh /usr/bin/ls
sh: csh: Execute permission denied.
by the way, is the "whence" and "which" command just the same? in my 5 years of IT work experience I never knew that there was a "whence" command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 05:46 PM
тАО10-04-2010 05:46 PM
Re: which command error, need help
# which for
no for in /usr/sbin /usr/bin /opt/ansic/bin /usr/ccs/bin /usr/contrib/bin /opt/hparray/bin /opt/nettladm/bin /opt/upgrade/bin /opt/fcms/bin /opt/resmon/bin /opt/pd/bin /opt/gnome/bin /opt/perf/bin /opt/ignite/bin /usr/contrib...etc
# whereis for
for:
# whence -v for
for is a keyword.
which is useless for aliases and shell builtins. Other examples:
# type type
type is an exported alias for whence -v
# type ulimit
ulimit is a shell builtin.
# type pwd
pwd is a shell builtin.
# alias pwd=/usr/bin/pwd
# type pwd
pwd is an alias for /usr/bin/pwd
type (whence) tells you what will happen if you type a string of characters. It finds shell aliases, keywords, basically anything that the shell does for you. This is much more useful than which and whereis.
HP provides the scummy C shell but that doesn't mean you should use it. Fir sysadmins, only a real shell (with standards like POSIX) like ksh or the POSIX shell sh (or even bash) provide consistent and portable results.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 08:50 PM
тАО10-04-2010 08:50 PM
Re: which command error, need help
-r-xr-xr-x 1 bin bin 664 Oct 4 18:04 /usr/bin/which
Do you have it for the scummy C shell?
ll /usr/bin/csh
While this is a rather clever trick to prevent users from using the scummy C shell, you should put the system back the way is was.
>is the "whence" and "which" command just the same? in my 5 years of IT work experience I never knew that there was a "whence" command.
Not really, though similar:
$ which csh
/usr/bin/csh # scummy C shell
$ whence -pv csh
csh is /usr/bin/csh
$ whence -v csh
csh is a tracked alias for /usr/bin/csh
If you know what makes the C shell scummy, you would know that which(1) is scummy too.
And real shell users, use whence. Since it is built into a real shell, it can tell you more things.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2010 09:01 PM
тАО10-04-2010 09:01 PM
Re: which command error, need help
which[7]: Syntax error at line 7 : `(' is not expected.
One other way to get this error is to link scummy csh to a real shell.
I get a different error if csh isn't executable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-05-2010 07:22 PM
тАО10-05-2010 07:22 PM