Demo entry 6633584

Output of pl2bat

   

Submitted by AJM on Aug 03, 2017 at 20:09
Language: Batchfile. Code size: 2.5 kB.

@rem = '--*-PERL-*--';
@rem = '
@echo off 
set COMMAND=%0
set ARGS=
:loop
if .%1==. goto endloop
set ARGS=%ARGS% %1
shift
goto loop
:endloop
goto goto end_of_file
@rem ';

($SCRIPT = $0) =~ s#.*/##;                   # Name of this script
$ERR="\n\007\rERROR:\t";                     # Error message.

# Ensure XX_ROOT is set.
( ! $ENV{XX_ROOT} ) && die "${ERR}The environment variable XX_ROOT must be set before running ${SCRIPT}";

# Derive XX_DATA variable if not already set.
if( $ENV{XX_DATA} eq "" ) 
{
    $ENV{XX_DATA} = "$ENV{XX_ROOT}\\xxdata";
}

# Ensure XX_DATA directory exists.
(! -d $ENV{XX_DATA} ) && die "${ERR}The XX_DATA directory $ENV{XX_DATA} must exist before running ${SCRIPT}";
    
# Set application name
$ENV{XX_APPLICATION} = "UGMAN";

# Unset XX_USER_UID_DIR and XX_APP_UID_DIR for the xxserver process.
# This is because 
#   (i) these 2 take precedence over XX_SYS_UID_DIR and 
#   (ii) we want to make sure we always run xxserver in vt100 mode.
$ENV{XX_USER_UID_DIR} = "";
$ENV{XX_APP_UID_DIR} = "";

# If XXSERVER_PORT not set then this is hard coded to 9999 in NX
if( $ENV{XXSERVER_PORT} eq "" ) 
{
    $ENV{XXSERVER_PORT} = "9999";
}

# Select VT100 mode
$ENV{MODE} = "vt";

if ( $ENV{ALREADY_SET} eq "" )
{
    # Now propagate all XX environment variables.
    # Set application variable if not already set.
    if ( -f "$ENV{XX_DATA}\\xx_setup.bat" )
    {
          @INC=("$ENV{XX_DATA}", @INC);
          require 'xx_setup.bat';
    }

    if ( -f "$ENV{XX_ROOT}\\local\\data\\xx_local_setup.bat" )
    {
          @INC=("$ENV{XX_ROOT}\\local\\data", @INC);
          require 'xx_local_setup.bat';
    }

    if ( -f "$ENV{XX_DATA}\\xx_profilevars.bat" )
    {
        # XX_load_env function to set XX environment in xx_profilevars.bat.
        &XX_load_env("$ENV{XX_DATA}\\xx_profilevars");
    }

    $ENV{ALREADY_SET} = "true";
}

system ("$ENV{XX_ROOT}\\bin\\xxserver.exe id=localserver -ORBEndpoint iiop://localhost:$ENV{XXSERVER_PORT}");

sub XX_load_env {
    open (ENV, "@_ & set |") || die "Can not create xx_profilevars pipeline: $!\n";
    while (<ENV>) {
        if (/^(\w+)=(.*)/)
        {
            $ENV{$1}="$2"; 
        }
    }
    close ENV;
}

__END__
@goto :end_of_file

:no_xxroot
@echo "The environment variable XX_ROOT is not set"
@echo "Exiting..."
@pause
@goto :end_of_file

:end_of_file

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).