su 명령어를 이용해서 계정을 자동으로 바꾸는 스크립트를 만들려고 합니 다. 그런데, 일반적으로
#su - aaa
하면, 패스워드를 치라고 나옵니다. 이부분이 문제인데요~~ 그것을 자동으로 입력할수 있게 할수는 없을까요?
expect 를 쓰세요...
#!/usr/bin/expect spawn bash -c "su -" expect -re "Password" sleep 0.2 send "xxxxxxx\r" interact
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
Re: [Bash] 자동 입력 하게 만들고 싶습니다.
expect 를 쓰세요...
#!/usr/bin/expect
spawn bash -c "su -"
expect -re "Password"
sleep 0.2
send "xxxxxxx\r"
interact
댓글 달기