"Bash 스크립트에 expect 스크립트 넣기"의 두 판 사이의 차이

(새 문서: ;쉘스크립트에 expect 문 넣기 ;Bash 스크립트에 expect 스크립트 넣기 ==방법 1: HEREDOC== ;예제 <source lang='bash'> #!/bin/sh USER=root IP=135.79.246.80 PW=P@s...)
 
3번째 줄: 3번째 줄:


==방법 1: HEREDOC==
==방법 1: HEREDOC==
;예제
<source lang='bash'>
<source lang='bash'>
#!/bin/sh
#!/bin/sh
USER=root
USER=testuser
IP=135.79.246.80
IP=135.79.246.80
PW=P@ssw0rd
PW=P@ssw0rd
20번째 줄: 19번째 줄:
==방법 2: 쌍따옴표==
==방법 2: 쌍따옴표==
<source lang='bash'>
<source lang='bash'>
#!/bin/sh
USER=testuser
IP=135.79.246.80
PW=P@ssw0rd
expect -c "
set timeout 3
spawn ssh -o StrictHostKeyChecking=no $USER@$IP 'whoami'
expect 'password:'
send \"$PW\\r\"
expect eof
"
</source>
</source>


25번째 줄: 35번째 줄:
*[[HEREDOC]]
*[[HEREDOC]]
*[[expect]]
*[[expect]]
==참고 자료==
*http://tamas.io/automatic-scp-using-expect-and-bash/


[[분류: bash]]
[[분류: bash]]
[[분류: expect]]
[[분류: expect]]

2013년 11월 27일 (수) 13:02 판

쉘스크립트에 expect 문 넣기
Bash 스크립트에 expect 스크립트 넣기

1 방법 1: HEREDOC

#!/bin/sh
USER=testuser
IP=135.79.246.80
PW=P@ssw0rd
expect <<EOF
set timeout 3
spawn ssh -o StrictHostKeyChecking=no $USER@$IP \"whoami\"
expect "password:"
	send "$PW\r"
expect eof
EOF

2 방법 2: 쌍따옴표

#!/bin/sh
USER=testuser
IP=135.79.246.80
PW=P@ssw0rd
expect -c "
set timeout 3
spawn ssh -o StrictHostKeyChecking=no $USER@$IP 'whoami'
expect 'password:'
	send \"$PW\\r\"
expect eof
"

3 같이 보기

4 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}