亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 循環(huán)中,執(zhí)行命令超過3秒沒返回,循環(huán)繼續(xù) [打印本頁]

作者: shijiang1130    時間: 2014-10-24 20:23
標題: 循環(huán)中,執(zhí)行命令超過3秒沒返回,循環(huán)繼續(xù)
open my $fh,'<','host.txt' or die "not open";

while (my $host= readline $fh){
...
    $result = `/bin/connect $host`;     //這個命令執(zhí)行超過3秒沒返回,while循環(huán)繼續(xù)下一個元素
...
}

erlang來做
作者: arserangel    時間: 2014-10-24 20:40
用 sys:cmd() ?
作者: shijiang1130    時間: 2014-10-24 20:57
不用進程:
  1. -module(timeout).
  2. -compile(export_all).

  3. r()->
  4.         {ok,S}=file:read_file("host.txt"),
  5.         %open my $fh,'<','host.txt' or die "not open";
  6.         H=binary:split(S,<<"\r\n">>,[global]),
  7.         to(H).
  8.         %while (my $host= readline $fh){
  9. %...

  10. to([])->
  11.         [];
  12. to([H|T])->
  13.           timer:sleep(100),
  14.         Str ="/bin/connect "++ erlang:binary_to_list(H),
  15.         io:format("run string is~p~n",[Str]),
  16.         os:cmd(Str),
  17.         to(T).
  18.     %$result = `/bin/connect $host`;     //這個命令執(zhí)行超過3秒沒返回,while循環(huán)繼續(xù)下一個元素
  19. %...
  20. %}
復制代碼

作者: shijiang1130    時間: 2014-10-24 20:57
  1. Eshell V6.2  (abort with ^G)
  2. 1> timeout:r().
  3. run string is"/bin/connect 1.1.1.2"
  4. run string is"/bin/connect 4.1.4.12"
  5. []
  6. 2>
復制代碼





歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2