start-xterms
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:5k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

C/C++

  1. #!/usr/bin/perl
  2. # ====================================================================
  3. # The Vovida Software License, Version 1.0 
  4. # Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. #    notice, this list of conditions and the following disclaimer in
  12. #    the documentation and/or other materials provided with the
  13. #    distribution.
  14. # 3. The names "VOCAL", "Vovida Open Communication Application Library",
  15. #    and "Vovida Open Communication Application Library (VOCAL)" must
  16. #    not be used to endorse or promote products derived from this
  17. #    software without prior written permission. For written
  18. #    permission, please contact vocal@vovida.org.
  19. # 4. Products derived from this software may not be called "VOCAL", nor
  20. #    may "VOCAL" appear in their name, without prior written
  21. #    permission of Vovida Networks, Inc.
  22. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
  23. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
  25. # NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
  26. # NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
  27. # IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
  28. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  31. # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  33. # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  34. # DAMAGE.
  35. # ====================================================================
  36. # This software consists of voluntary contributions made by Vovida
  37. # Networks, Inc. and many individuals on behalf of Vovida Networks,
  38. # Inc.  For more information on Vovida Networks, Inc., please see
  39. # <http://www.vovida.org/>.
  40. my $sxt_path = $ARGV[0];
  41. my $bin_path = $ARGV[1];
  42. if (! (defined $bin_path && defined $sxt_path)) {
  43.     print STDERR <<EOF;
  44. Usage: $0 filename.sxt path_to_binaries
  45. EOF
  46.     exit 1;
  47. }
  48. if ((! -e "./session.exp") || (! -e "./interact.exp")) {
  49.     print "Can't find session.exp or/and interact.expn";
  50.     print "Please copy the files to current directoryn";
  51.     exit( 1 );
  52. }
  53. # Date information to be used for file extensions etc
  54. $datetime = time();
  55. $rootpf = ".$datetime.tmp";
  56. $datetime++;
  57. $userpf = ".$datetime.tmp";
  58. # save info required for a session
  59. $syscmd = "./session.exp $rootpf $userpf";
  60. system( $syscmd ); 
  61. open(F, $sxt_path) || die "can't open $ARGV[0]: $!";
  62. while(<F>) {
  63.     chomp;
  64.     s/#.*$//;
  65.     if(!/^s*$/) {
  66.         eval("@cmds = ($_)");
  67.         if($#cmds == 3) {
  68.             &start_xterm('0', @cmds);
  69.         }
  70.         if($#cmds == 4) {
  71.             &start_xterm(@cmds);
  72.         }
  73.     }
  74. }
  75. close(F);
  76. print ".... now starting the servers,  please waitn";
  77. sleep( 25 );
  78. system( "rm /tmp/$rootpf /tmp/$userpf" );
  79. sub start_xterm {
  80.     my($sleep, $title, $ssh_arg, $geometry, $ctrl_f10) = @_;
  81.     my($xrdb_stuff, $ssh_cmdline, $syscmd);
  82.     my($commands, $cd_dir, $resources_cmdline);
  83.     my($title_cmdline);
  84.     my($host) = $ssh_arg;
  85.     $host =~ s/@//;
  86.     $host =~ s/^/@/;
  87.     $title_cmdline = "-T '$title $host' -n '$title $host'";
  88.     $geometry_cmdline = "-geometry $geometry";
  89.     $cd_dir = "cd " . `pwd`;
  90.     $pwd = `pwd`;
  91.     chop( $pwd );
  92.     chomp($cd_dir);
  93.     $cd_dir .=  '\n';
  94.     $xrdb_stuff = 'xterm*VT100.Translations: #override <Key>F10: ' . 
  95.                   'string("' . $cd_dir . '")' . ' ' . 
  96.                   'string("' . $ctrl_f10 . '")';
  97.     $resources_cmdline = "-xrm '$xrdb_stuff'";
  98.     chomp($username = `whoami`);
  99.     $ssh_arg =~ s/^@/$username@/;
  100.     $commands = $ctrl_f10;
  101.     $commands =~ s/\n/;/g;
  102.     $commands = '''. "$commands" . ''';
  103.     if($ssh_arg eq "-") {
  104.         $ssh_cmdline = "-e ./interact.exp " .
  105.                        "$sleep $pwd localhost $rootpf $userpf $commands";
  106.     } else {
  107.         $ssh_cmdline = "-e ./interact.exp " .
  108.                        "$sleep $pwd $ssh_arg $rootpf $userpf $commands";
  109.     } 
  110.   
  111.     $syscmd = "xterm $resources_cmdline -sl 10000 $geometry_cmdline " .
  112.               "$title_cmdline $ssh_cmdline &";
  113.     system ($syscmd);
  114. }