参考Login_osgi.sh脚本:
#/bin/bash
# Destription:Login osgi
# parameters: sh Login_osgi.sh
# Auther: xxxxx
# Date: 2015-5-15
function Login_osgi()
{
/usr/bin/expect <<\EOF
set timeout 60
set commod [lindex $argv 0]
#telnet本地的osgi 端口12501
spawn telnet localhost 12501
expect "osgi>"
send "$commod\n"
expect "osgi>"
#列举bundle加载状态
send "ss\n"
#退出osgi
send "disconnect\n"
#确认退出osgi
expect "Disconnect from console? (y/n; default=y)"
send "y\n"
expect eof
EOF
}
Login_osgi $@
exit 0