#!/bin/bash

# This file is part of IKR SimTree
# (C) 2009-2014 University of Stuttgart, IKR

# Hook file template which executes a simulation through SimTree exec on a remote host
# Must return 255 when the remote execution failed (like ssh does)
# Other values are return value of the called command

# %%HOOK_FILE_SOURCE_COMMENT%%

# For control to work, stdin, stdout and stderr must be passed transparently up/down

### Parameters

# The name of the command with all its parameters
COMMAND="%%COMMAND%%"

# The name of the host where the command should be executed
REMOTE_HOSTNAME="%%REMOTE_HOSTNAME%%"

############
### Main

exec /usr/bin/ssh $REMOTE_HOSTNAME ". /etc/profile; exec $COMMAND"

# exec will not return except in case of exec failure

exit $?

# End of file
