Serge Rogatch
Serge Rogatch

Reputation: 15100

How to get the PATH variable on the remote machines with mpirun?

I've tried

mpirun -n $N_HOSTS -host $MPI_HOSTS echo $PATH

But this way, it prints me the PATH variable from the launching machine, rather than each machine printing the $PATH variable for itself. The substitution happens on the launching machine.

When I run either of

mpirun -n $N_HOSTS -host $MPI_HOSTS echo \$PATH
mpirun -n $N_HOSTS -host $MPI_HOSTS echo '$PATH'

The substitution doesn't happen on either host.

How to make each machine return its own PATH variable?

Upvotes: 0

Views: 203

Answers (1)

Fravadona
Fravadona

Reputation: 17250

You could mpirun a shell for expanding $PATH, but launching a shell involves reading rc files so the result might be inaccurate. I would use a command that can output environment variables directly, like env or awk:

mpirun -n "$N_HOSTS" -host "$MPI_HOSTS" awk 'BEGIN{print ENVIRON["PATH"]}'

Upvotes: 1

Related Questions