shell script

dngml112의 이미지

shell script를 작성할 때,
다음 사진과 같이 비밀번호를 작성해야하는 데, 자동으로 입력하려고 합니다. 방법이 없을까요?

File attachments: 
첨부파일 크기
Image icon 이미지 30.png4.67 KB
익명 사용자의 이미지

yes 패스워드 | shell script 명

김정균의 이미지

here string 이나 here document 를 사용하시면 될 것 같은데요.

입력을 한번만 물어볼 경우, (here string)

[user@host ~]$ ./sh.sh << password

입력을 3번 물어볼 경우 (here document)

[user@host ~]$ ./sh.sh <<<EOL
password
password
password
EOL