environment modules interaction with ssh

Environment modules is a nice software environment that lets you switch verilog simulator version very easily without having to edit your environment (.cshrc or other). But it seems to have some drawbacks. One of which is that is does not return proper exit status when it fails, making it hard to write scripts that fail when they should. The other one is it does not play well with ssh, or so it seems.

When I hit ctrl-c on VCS at runtime, it will drop the command line interface, aka the verilog CLI. When I try to make this work with ssh and environment modules, I have a nasty surprise: environment modules interferes somewhere.

Let’s first emulate the verilog command line with a simple script, since you don’t need an expensive verilog simulator to see the problem:

$ cat prog

# This program traps INT and queries the user for input

function process_int {
  echo -n "cli> "
  read LINE
  echo to stdout $LINE
  echo to stderr $LINE >&2
  exit 2

trap process_int SIGINT
echo test stdout
echo test stderr >&2
sleep 30

Next, we want to run this script through ssh and environment modules, hit ctrl-c and be dropped to the cli> prompt:

$ ssh -t localhost 'tcsh -c "source Modules/init/tcsh && module list && ./prog"'

Currently Loaded Modulefiles:
  1) make/3.81a
test stdout
test stderr

Connection to localhost closed.

Well, this did not drop to the command line interface. Let’s try without module list:

$ ssh -t localhost 'tcsh -c "source Modules/init/tcsh && ./prog"'
test stdout
test stderr
cli> t
to stdout t
to stderr t

Connection to localhost closed.

This time, it has let me typed something on the cli> command line prompt. Okay, so there is some interaction between ssh and modules. I’ve struggled with this for a few days and it is getting annoying. The same commands will work with rsh, but rsh does not return the a proper exit status, so I really do want to use ssh.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: