SunOS 5.10 "이" [중복]

SunOS 5.10 "이" [중복]

나는 SunOS 5.10 시스템에 대한 (일반 사용자) 액세스 권한을 가지고 있습니다.

/usr/bin/which손상되었습니다(차단됩니다).

시스템에 문제가 있는 것은 분명하지만 루트 액세스 권한이 없으면 수행할 수 있는 작업이 크게 제한됩니다. Ubuntu에서 복사를 시도했지만 which이는 SunOS 5.10에서 사용할 수 없는 기능에 따라 다릅니다.

$ md5sum /usr/bin/which
a39bb82e9e354c5b99e9e235a53c48d9  /usr/bin/which
$ uname -a
SunOS solaris 5.10 Generic_147147-26 sun4u sparc SUNW,Sun-Fire-V210 Solaris
$ bash --version
GNU bash, version 4.3.33(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

which이 이전 시스템에 대한 명령은 어디서 찾을 수 있나요 ?

답변1

which명령은 Solaris 10에서는 깨질 가능성이 없습니다. 그것은 단지 script1csh 입니다 .

이 스크립트 내용이 실제로 손상된 경우 다음 줄을 복사하여 붙여넣어 바꿀 수 있습니다. 그러면 표준 동작이 복원됩니다.

#! /usr/bin/csh -f
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Copyright (c) 1980 Regents of the University of California.
# All rights reserved.  The Berkeley Software License Agreement
# specifies the terms and conditions for redistribution.
#
#ident  "%Z%%M% %I% %E% SMI"
#
#       which : tells you which program you get
#
# Set prompt so .cshrc will think we're interactive and set aliases.
# Save and restore path to prevent .cshrc from messing it up.
set _which_saved_path_ = ( $path )
set prompt = ""
if ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc
set path = ( $_which_saved_path_ )
unset prompt _which_saved_path_
set noglob
set exit_status = 0
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        # head != tail, don't search
        if ( -e $arg ) then         # just do simple lookup
            echo $arg
        else
            echo $arg not found
        set exit_status = 1
        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
    set exit_status = 1
    endif
end

exit ${exit_status}

그러나 중단의 보다 일반적인 원인은 which.txt 파일에 나열된 디렉터리에서 사용하는 파일 시스템 중 하나에 문제가 있기 때문입니다 PATH.

이는 NFS 마운트가 응답하지 않거나 로컬 파일 시스템에 문제가 있을 수 있습니다.

조사를 시작하는 한 가지 방법은 다음과 같습니다. 이 명령을 실행하고 어디에서 멈추는지 확인하세요.

csh -x /bin/which foo

정지가 발생할 수 있는 또 다른 이유는 파일이 스크립트 시작 부분에서 발생하므로 which파일에 문제가 있기 때문일 수 있습니다 ..cshrc

1 스크립트 이기 때문에 설계상 문제가 있다고 말할 수도 있습니다 ;-)cshwhich

답변2

나는 갔었다:

#!/bin/sh

type "$@" | perl -pe 's/.* is (a tracked alias for )?//'

이런 식으로 드롭인 대체품으로 사용할 수 있습니다 which.

의견을 주신 @OlafDietsche에게 감사드립니다.

관련 정보