+ -
当前位置:首页 → 问答吧 → 求高手翻译perl脚本语言

求高手翻译perl脚本语言

时间:2011-07-04

来源:互联网

sub sendMessage
  {  
  my $tricomIP ="111.222.217.235";
  my $port=10000;
  my $phone=12345678;
   
  if (!$tricomIP) 
  {
  print "please input remote server running tricom!\n";
  print "Usage: $0 <remote_server_hostname_or_ip>\n";
  exit 0;
  }
   
  print "\$tricomIP=$tricomIP\n";
  my $console = new Net::Telnet(Timeout=>180); 

  $console->open(Host=>$tricomIP,Port=>$port);
   
  unless($console->waitfor(String=>'Welcome to Tricom',Timeout=>5))#waiting for the welcome message from server
  {
  print "Please startup the remote server first!\n";
  exit;
  }
  for(;;)
  {
  $console->print("at\n");
  if($console->waitfor(String=>'OK',Timeout=>5))
  {
  print "'OK' comes! sms modem is working.\n";
  last;
  }
  else
  {
  print "'OK' does not come! please check sms modem.\n";
  }
  sleep(1); 
  }
   
  $console->print("at+CMGF=1\n");
  sleep(1);
  for(;;)
  {
   
  $console->print("at+CMGS=\"$phone\"\n");
  sleep(1);
  $console->print(@_);
  $console->print("\n");
  sleep(1);
  $console->print("`");
  $console->print("\n");
  if($console->waitfor(String=>'OK',Timeout=>5))
  {
  print "'OK' comes! message is sent successful.\n";
  last;
  }
  else
  {
  print "'OK' does not come! message is not sent successful.\n";
  }
  sleep(1); 
  }
 
   
  }#end of sub
这是一段perl脚本语言,由于小弟没有接触过,所以请求高手将它翻译成vc的语言,万分感谢!

作者: tonywei57   发布时间: 2011-07-04

有依赖模块,翻译不了。你为啥要翻译成VC的?

另外你要只是想看懂,自己先找本Perl书看比较好。代码本身没什么复杂度。

作者: iambic   发布时间: 2011-07-04