kalor

导航

 

 

今天想在expect脚本中获取本机ip,执行脚本是报错,脚本如下:

set localip [exec ifconfig eth0 | grep Mask | cut -d: -f2 | awk '{print $1}]

solution :exec sh -c {your commands here}

 获取ip的脚本可以写成:

set idcid [exec sh -c {ifconfig eth0 | grep Mask | cut -d: -f2 | awk '{print $1}'}]


参考资料:

1. http://www.linuxquestions.org/questions/linux-software-2/ksh-tcl-173092/

2. http://blog.csdn.net/bonny95/article/details/5786283

3. http://wiki.tcl.tk/1039

posted on 2014-05-04 14:46  kalor  阅读(2149)  评论(0编辑  收藏  举报