home *** CD-ROM | disk | FTP | other *** search
/ IBM Presents OS/2 Software Hits 1995 / OS-2_SW_HITS_2ND_EDITION_1995.ISO / i17 / pmx20c2.exe / PMXC2.ZIP / BIN / XINIT.CMD < prev    next >
OS/2 REXX Batch file  |  1994-05-20  |  10KB  |  292 lines

  1. /* xinit.cmd
  2.     This is a sample XINIT.CMD file which starts PMX server.
  3.  
  4.     It requires the environment variables XFILES and HOSTNAME
  5.     to be set up during TCP/IP installation.
  6.  
  7.     The following national language keyboard definitions are being distributed.
  8.     They are copied unchanged from RS/6000 AIX 3.1 and AIX 3.2.
  9.     You can choose which AIX version of the keyboard definition files get
  10.     used by setting the optional PMXUNIX OS/2 environment variable:
  11.        set PMXUNIX=AIX3.1
  12.        or
  13.        set PMXUNIX=AIX3.2      <== the default if PMXUNIX is not set
  14.  
  15.     Set the OS/2 environment variable LANG with the desired national keyboard.
  16.     For example, if you want the Italian keyboard definition, you could
  17.     add the following line to your CONFIG.SYS file.  LANG defaults to
  18.     US English if it is not found in the OS/2 environment.
  19.        set LANG=it_IT
  20.  
  21.      Language            LANG=value       Language            LANG=value
  22.      --------            ----------       --------            ----------
  23.      Belgian             nl_BE            Latin Amer. Spanish es_LA
  24.      Belgian French      fr_BE            Norwegian           no_NO
  25.      Canadian French     fr_CA            Portuguese          pt_PT
  26.      Danish              da_DK            Spanish             es_ES
  27.      Dutch               nl_NL            Swedish             sv_SV
  28.      Finnish             fi_FI            Switzerland French  fr_CH
  29.      French              fr_FR            Switzerland German  de_CH
  30.      German              de_DE            Turkish             tr_TR
  31.      Greek               el_GR            United Kingdom      en_GB
  32.      Icelandic           is_IS            United States       en_US
  33.      Italian             it_IT
  34.      Japanese            ja_JP
  35.      Japanese English    en_JP
  36.  
  37.      An optional PMXKEYBOARD OS/2 environment variable can be set to select
  38.      the type of keyboard that PMX uses.  This environment variable is only
  39.      important when LANG=ja_JP, since there are three different Japanese
  40.      keyboards available.
  41.  
  42.      PMX supports the following keyboards:
  43.  
  44.      Keyboard type                 PMXKEYBOARD= or '-k' flag value
  45.      ----------------------------  -------------------------------
  46.      101 key                       101
  47.      102 key                       102
  48.      Japanese 5576-A01 (106 keys)  5576-A01 or 5576A01 or 106A <== LANG=Jp_JP default
  49.      Japanese 5576-001 (124 keys)  5576-001 or 5576001 or 124
  50.      Japanese 5576-002 (106 keys)  5576-002 or 5576002 or 106
  51.  
  52. .....................................................................
  53. If some of this information scrolled off the top of your screen try:
  54.    xinit ? | more
  55. or
  56.    xinit ? > xinit.doc
  57.    e xinit.doc
  58. .....................................................................
  59. ###
  60. */
  61. trace o
  62.  
  63.   parse arg args
  64.  
  65.   JpJPdefaultKeyboard = '5576-A01'
  66.  
  67.   /*
  68.    *   Provide XINIT HELP text
  69.    */
  70.   if args='?' | args='-h' | args='/h' then
  71.      do
  72.      i = 2
  73.      help = sourceline(i)
  74.      do while help <> '###'
  75.         say help
  76.         i = i+1
  77.         help = sourceline(i)
  78.         end /*dowhile*/
  79.      exit 0
  80.      end /*endif*/
  81.  
  82.  /*
  83.   *  Check to see if PMX is already running:
  84.   */
  85.   'pmxwait -q 0'    /* See if the server is running */
  86.  
  87.   if rc = 0 then
  88.      do
  89.      /* PMX is already running! */
  90.      say "PMX is already running! PMXWAIT rc=" rc
  91.      exit 2
  92.      end
  93.  
  94.   /*
  95.    *  if there is a PMXFLAGS environment variable, then prefix args with it:
  96.    */
  97.   pmxflags = VALUE('PMXFLAGS',,'OS2ENVIRONMENT')
  98.   args = pmxflags args
  99.   /*
  100.    *  Process the *required* XFILES and HOSTNAME enviornment variables:
  101.    */
  102.   XFiles =  VALUE('XFILES',,'OS2ENVIRONMENT')
  103.   if XFiles = '' then
  104.     do
  105.     say "XFILES environment variable is not defined. PMX is not started!"
  106.     exit 1
  107.     end
  108.   Hostname =  VALUE('HOSTNAME',,'OS2ENVIRONMENT')
  109.   if Hostname = '' then
  110.     do
  111.     say "HOSTNAME environment variable is not defined. PMX is not started!"
  112.     exit 1
  113.     end
  114.  
  115.   /* Create a DISPLAY environment variable: */
  116.   'set DISPLAY=' || Hostname || ':0'
  117.  
  118.   /*
  119.    *  Process the -pmx flag or the PMXVERSION environment variable:
  120.    */
  121.   if (0<>WORDPOS( '-pmx' , args )) then
  122.      do
  123.      pmxPos     = WORDPOS( '-pmx' , args )
  124.      pmxVersion = SUBWORD( args , pmxPos+1 , 1 )
  125.      args       = DELWORD( args , pmxPos , 2 )
  126.      end /*if WORDPOS*/
  127.   else
  128.      do
  129.      pmxVersion = VALUE('PMXVERSION',,'OS2ENVIRONMENT')
  130.      if pmxVersion = '' then pmxVersion='PMX.EXE'
  131.      end /*if WORDPOS else*/
  132.  
  133.   /*
  134.    *  Process the -lang flag or the LANG environment variable:
  135.    */
  136.   lang=''
  137.   if (0<>WORDPOS( '-lang' , args )) then
  138.      do
  139.      langPos = WORDPOS( '-lang' , args )
  140.      lang    = SUBWORD( args , langPos+1 , 1 )
  141.      args    = DELWORD( args , langPos , 2 )
  142.      end /*if WORDPOS*/
  143.   else
  144.     if (0=WORDPOS('-ignoresavedsettings', args)) then
  145.       do forever
  146.         lang = ''
  147.         ini_path=VALUE('ETC',,'OS2ENVIRONMENT')
  148.         if ini_path='' then leave
  149.         ini_path = ini_path || '\PMX.INI'
  150.         ini_path = stream(ini_path,'c','QUERY EXISTS');
  151.         if ini_path='' then leave
  152.         RC=RXFUNCQUERY('SysIni')
  153.         if (RC<>0) then do
  154.           RC=RXFUNCADD('SysIni','REXXUTIL','SysIni')
  155.           if (RC<>0) then leave
  156.         end
  157.         lang=STRIP(SysIni(ini_path,'Notebook1','language'), 't', '00'x)
  158.         /* say xx||lang||xx */
  159.         if ((lang='') | (lang = 'ERROR') | (lang = 'ERROR:')) then do
  160.           lang=''
  161.           leave
  162.         end
  163.         leave
  164.       end
  165.  
  166.   if (lang='') then do
  167.      lang = VALUE('LANG',,'OS2ENVIRONMENT')
  168.                 /*** Modify 'En_US' below to have a different default keyboard ***/
  169.      if lang = '' then lang='En_US'
  170.   end /* if lang='' */
  171.  
  172.   lang = translate(lang)
  173.   /*
  174.    *  Allow LANG shortcut:  translate "jpjp" to "JP_JP"
  175.    */
  176.   if length(lang)=4 then
  177.      do
  178.      lang = substr( lang , 1 , 2 ) || "_" || substr( lang , 3 , 2 )
  179.      end
  180.  
  181.   /*
  182.    *  Check to see if "-k" flag appears in the XINIT args
  183.    */
  184.   if (0<>WORDPOS( '-k' , args )) then
  185.      kbdopt = ''
  186.   else
  187.      do
  188.        kbdopt = translate(VALUE('PMXKEYBOARD',,'OS2ENVIRONMENT'))
  189.        if kbdopt<>'' then
  190.           kbdopt = '-k' kbdopt
  191.        else
  192.           do
  193.             /*
  194.              *  Check INI file for keyboard type.
  195.              *  If it is not found, then
  196.              *  Infer keyboard type from LANG setting
  197.              */
  198.             if (0=WORDPOS('-ignoresavedsettings', args)) then
  199.               do forever
  200.                 ini_path=VALUE('ETC',,'OS2ENVIRONMENT')
  201.                 if ini_path='' then leave
  202.                 ini_path = ini_path || '\PMX.INI'
  203.                 ini_path = stream(ini_path,'c','QUERY EXISTS');
  204.                 if ini_path='' then leave
  205.                 RC=RXFUNCQUERY('SysIni')
  206.                 if (RC<>0) then do
  207.                   RC=RXFUNCADD('SysIni','REXXUTIL','SysIni')
  208.                   if (RC<>0) then leave
  209.                 end
  210.                 kbdopt=STRIP(SysIni(ini_path,'Notebook1','Keyboard'), 't', '00'x)
  211.                 /* say xx||kbdopt||xx */
  212.                 if ((kbdopt='') | (kbdopt = 'ERROR:')) then do
  213.                   kbdopt=''
  214.                   leave
  215.                 end
  216.                 kbdopt='-k' kbdopt
  217.                 leave
  218.               end /* end do forever */
  219.  
  220.             if kbdopt='' then do
  221.               select
  222.                 when lang = 'EN_US' then
  223.                    kbdopt = '-k 101'
  224.                 when lang = 'JP_JP' | lang = 'EN_JP' then
  225.                    kbdopt = '-k' JpJPdefaultKeyboard
  226.                 otherwise
  227.                    kbdopt = '-k 102'
  228.               end /* end select */
  229.             end /* if kbdopt='' */
  230.           end /*if kbdopt<>''*/
  231.      end /*if WORDPOS*/
  232.  
  233.   /*
  234.    *  Process the PMXUNIX environment variable or the "-unix" flag:
  235.    */
  236.   if (0<>WORDPOS( '-unix' , args )) then
  237.      do
  238.      unixPos = WORDPOS( '-unix' , args )
  239.      unix    = SUBWORD( args , unixPos+1 , 1 )
  240.      args    = DELWORD( args , unixPos , 2 )
  241.      end /*if WORDPOS*/
  242.   else
  243.      unix = VALUE('PMXUNIX',,'OS2ENVIRONMENT')
  244.  
  245.   unix = translate(unix)
  246.   select
  247.   when unix = 'AIX3.1' then keyboardSuffix = '._31'
  248.   when unix = 'AIX3.2' then keyboardSuffix = ''
  249.      /*
  250.       * -- you may wish to add other unix types here:
  251.       *    ... be sure to copy the correct keyboard.??? files over
  252.       *        to \tcpip\x11\defaults\xmodmap\??_?? subdirectories
  253.       * eg:
  254.       *  when unix = 'SUNx.x' then keyboardSuffix = '.SUN'
  255.       */
  256.   otherwise                    keyboardSuffix = '' /* PMXUNIX default is AIX3.2 */
  257.   end /*select*/
  258.  
  259.   'START' pmxVersion args kbdopt
  260.  
  261.   'pmxwait -v 60'    /* wait until the server is running */
  262.  
  263.   if rc <> 0 then
  264.      do
  265.      /* PMX is not running! */
  266.      say "XINIT Failure: PMX does not seem to be running! PMXWAIT rc=" rc
  267.      exit 2
  268.      end
  269.  
  270.   'xmodmap 'XFiles'\DEFAULTS\XMODMAP\'lang'\keyboard'keyboardSuffix
  271.  
  272.   /*
  273.    * Uncomment the following line if you want host machines *NOT*
  274.    * appearing in \tcpip\etc\x0hosts to connect to PMX
  275.    */
  276.   /* 'xhost +' */   /* DISABLE PMX access control */
  277.  
  278.   /*
  279.    * At this point, call xinitrc.cmd from the %etc% directory.  You can put
  280.    * any user-specific configuration in that file.  That way, you won't
  281.    * have to modify xinit.cmd.
  282.    */
  283.    do forever
  284.      xinitrc_path=VALUE('ETC',,'OS2ENVIRONMENT')
  285.      if xinitrc_path='' then leave
  286.      xinitrc_path = xinitrc_path || '\XINITRC.CMD'
  287.      xinitrc_path = stream(xinitrc_path,'c','QUERY EXISTS');
  288.      if xinitrc_path='' then leave
  289.      "call" xinitrc_path
  290.      leave
  291.    end
  292.