Index: term_com.js =================================================================== --- term_com.js (revision 32) +++ term_com.js (revision 35) @@ -290,7 +290,7 @@ if (flg_node){ pause(1); flushrecv(); - var cur_ip = ''; + var cur_ip = null; if (this.server_prompt_suffix){ var cmd = "ipconfig | grep 'IPv4 Address'"; // var cmd="ip address show eth0"; sendln(cmd); @@ -302,13 +302,24 @@ } else { // var cmd = "ip address show | grep eth"; // var cmd="ip address show eth0"; - var cmd = "ip address show | grep $(ip address show| grep ^2:| cut -d : -f 2)"; - sendln(cmd); - var mt = ToJSArray(waitregex("inet\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)/\\d+\\s+brd\\s+[\\d.]+\\s+scope global")); - if (mt[0] == 0){ - throw "Time out"; // 扔出一个错误。 + var num=2; + do{ + var cmd = "ip address show | grep \"$(ip address show| grep ^"+num+":| cut -d : -f 2)\""; + sendln(cmd); + var mt = ToJSArray(waitregex("inet\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)/\\d+\\s+brd\\s+[\\d.]+\\s+scope global", 3)); + if (mt[0] == 0){ + if ( num > 2 ){ + throw "Time out"; // 扔出一个错误。 + } + else{ + num++; + } + } + else{ + cur_ip = mt[1]; + } } - cur_ip = mt[1]; + while(!cur_ip) } this.current_ip = cur_ip; @@ -520,6 +531,7 @@ wait_list.push(obj[0]); } wait_list.push(l_prompt); + var run_flg=0 while(true){ var ret = wait(wait_list); if (ret == 0){ @@ -530,7 +542,8 @@ if (ret