set file "/tmp/vars.exp"
#source vars.exp
source vars.exp
source procs.exp
source tools.exp

# NO Authenticate window
set env(TTA_AllowThirdTierDialog) "none"  
set env(TTA_DomainName) "ttarima"

# Uncomment to turn on the extra debug - lots of information so default is off
# startdebug

# Try to optimise 
optimiselaunch

set args(DirCachePath) "/tmp/"
set spos [string last "/" $env(TTA_LOGFILE)]
set pos [expr $spos+1]
set lon [string last ".log" $env(TTA_LOGFILE)]
set args(ExpFile) $args(DirCachePath)[string range $env(TTA_LOGFILE) $pos $lon]exp
set args(scan_ttacachePath) "/opt/tarantella/tools"
set args(scan_ttacacheCmd) "scanttacache"

# Normal launch procedure
initialise

# For debugging ...
log_file "/tmp/ttalog"
dump_env

system "cd $args(scan_ttacachePath); ./$args(scan_ttacacheCmd) >$args(ExpFile)"
system "chown bin:bin $args(ExpFile)"
source $args(ExpFile)
system "rm -f $args(ExpFile)"

#preexpbefore
if {$env(TTA_COMMAND) != ""} {
    if {$env(TTA_CONNECTIONSERVICE) != "shell" && $env(TTA_CONNECTIONSERVICE) != "exec" && $env(TTA_CONNECTIONSERVICE) != "rcmd"} {
	login
	startshells
    } else {
	# For the exec and shell services there is no interaction
	# therefore we ensure prompt detection always succeeds by
	# matching anything
	set prompts(prompt) ""
	expect *
    } 
    setupenv
    mansetupenv
    runauxcommands
    runmaincommand
} else {
    expect "\n"
    scriptcomplete
}



















