SSH를 통해 스크립트를 실행할 때 터미널 프롬프트를 얻을 수 없습니다

SSH를 통해 스크립트를 실행할 때 터미널 프롬프트를 얻을 수 없습니다

로컬로 실행할 때 잘 작동하는 다음 스크립트가 있습니다.

고양이/tmp/input.sh

                echo -n ">> "
                read env
                exit;

실행하면 아래와 같이 명령 프롬프트가 나타납니다.

$/tmp/input.sh | echo "whatever"
$

여태까지는 그런대로 잘됐다. SSH를 통해 이 스크립트를 실행할 때 문제가 발생합니다.

ssh wladmin@myhost /tmp/input.sh | echo "whatever"

This system is for the use by authorized users only. All data contained
on all systems is owned by the company and may be monitored, intercepted,
recorded, read, copied, or captured in any manner and disclosed in any
manner, by authorized company personnel. Users (authorized or unauthorized)
have no explicit or implicit expectation of privacy. Unauthorized or improper
use of this system may result in administrative, disciplinary action, civil
and criminal penalties. Use of this system by any user, authorized or
unauthorized, constitutes express consent to this monitoring, interception,
recording, reading, copying, or capturing and disclosure.

IF YOU DO NOT CONSENT, LOG OFF NOW.

##################################################################
# *** This Server is using Centrify                          *** #
# *** Remember to use your Active Directory account          *** #
# ***    password when logging in                            *** #
##################################################################

보시다시피, 명령 프롬프트 터미널에서 제어권을 가져갈 것으로 예상하지만, 뭔가를 $누르지 않으면 Crtl + C추가 입력을 위한 명령 프롬프트가 표시되지 않습니다 .

옵션을 시도했지만 ssh -T도움이 되지 않았습니다.

무엇을 해야 하는지 제안해 주실 수 있나요?

답변1

해당 줄의 스크립트는 스크립트의 입력을 허용하지 않기 때문에 echo "whatever"종료 됩니다 . 따라서 이런 일이 발생하지 않습니다. 왜 이렇게 하는지는 모르겠지만 어쨌든 계속 진행됩니다. ssh를 사용하면 input.sh 스크립트만 원격으로 실행되며 stdout에 대한 텍스트가 거부된다는 사실을 "알지" 못합니다. 동일한 효과를 얻으려면 모든 것을 원격으로 실행하십시오(예: 인용 또는 이스케이프 처리).echo -n ">> "read env|echo|

ssh wladmin@myhost /tmp/input.sh \| echo "whatever"

관련 정보