Re: How to execute a single command with a login environment?

unruh <unruh@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 2010-07-16, tinnews@xxxxxxxxxx <tinnews@xxxxxxxxxx> wrote:
unruh <unruh@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 2010-07-15, tinnews@xxxxxxxxxx <tinnews@xxxxxxxxxx> wrote:
I want to run a single command via ssh on a remote system:-

ssh <name of system> <command>

but I want my normal user environment that I'd get if I had executed
"ssh <name of system>" and then running the command from the bash
prompt. Apart from writing a wrapper script that sources .profile and
.bashrc (or whatever) is there a more straightforward way of doing

It is. But it is not done using a login environment since you do not
have a console to which the stuff could be sent. Maybe you should tell
us what you want to run, and what theproblem you are having is, rather
than asking how to impliment the solution you imagine would work.

I want to run mutt.

If I just do "ssh snake1 mutt" then I get errors about missing scripts
because the PATH isn't set up right. (The scripts are used by my
muttrc file).

ssh snake1 'export PATH=$PATH:/my/mut/scripts/dir:/my/other/dir; mutt'

I suspect that other things won't work due to environment expected by
mutt as well but I haven't got as far as checking that.

My suspicions were right, I now get no error message about missing
scripts but the connection just hangs - no output at all.

Chris Green


Relevant Pages

  • Re: organizing your scripts, with plenty of re-use
    ... boilerplate that installation to the PYTHONPATH was supposed to avoid. ... PYTHONPATH an environment variable that the user can set. ... developers without much options beyond "all scripts in one directory" ...
  • Re: Where is su profile??
    ... My problem is, where is the profile ... I moved all of our admin scripts ... The environment includes the HOME environment ... 'su -' produces a shell that is considered a "login ...
  • Re: How to provide editor environment on
    ... In shell scripting, at least with bash, taking input from user is done ... an editor like environment when answering. ... I've included an edited piece of one of my homeboy scripts that takes ...
  • Re: Should I redefine PATH in my shell scripts
    ... This is not true for many of the environments my scripts need to run in. ... clear error messages telling them what the real problem is instead of ... Which is why if you expect certain commands in certain places you should ... but I wasn't thinking in terms of the environment you work in. ...
  • Re: putenv
    ... and I'd like to use env variables as kind of a global variable that I can pass around to the pythong scripts. ... the calling csh script (or, by extenstion, the environment ... of subsequent python programs that are called by the csh ... csh source command reads commands from the file named as an argument. ...