#!/usr/bin/tclsh
#
# This file is part of Helga.
#
# Helga is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Helga is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Helga. If not, see .
#
#
# helgatcp
#
# Meant to be run in the background. Loads the Helga Tcl libraries,
# then starts a tcp server listening. See proc tcpEval in file
# lib/command.tcl for more info on how to use this server.
#
#
# Parse user-given arguments
#
if { $argc < 1 } {
puts "Error: usage: helgatcp \[\]"
exit 1
}
set user [lindex $argv 0]
set pass [lindex $argv 1]
#
# Load the Helga Tcl libraries
#
package require helga 1.0
#
# If we try to run the following hlogin command immediately, an
# error will sometimes be generated because session IDs are time-based.
# Wait so we end up generating a unique session ID.
#
after 1000
#
# Log in to Helga
#
hlogin $user $pass
#
# Return some session info so the initiating program knows how to
# contact the now-running Shell.
#
puts "{\"id\":\"$::session(sessionId)\",\"port\":[::helga::user::getSessionPort]}"
#
# Start up the Helga persistant server
#
::helga::command::startServer
#
# Start waiting for commands
#
vwait forever