3
2
I have a shell script which I simply cannot do without: bar from Theiling Online
I use SSH a lot and on a variety of *nix servers. However, I am not a system administrator and usually don't have the time or privileges to install it on every server I connect to.
It is apparently a very portable sh
script and has command line options to export itself as a shell function, which got me thinking: Could I use one of OpenSSH's subjectively obscure features to export it everywhere I go?
My first thought was to assign the source to an environment variable like BAR = "cat -v"
and then execute it on the other side as `$BAR`, but 1) I can't even get the cat example to to work locally, 2) I don't know how to put the script's actual multiline source into an environment variable and 3) I have yet to see a machine with PermitUserEnvironment
enabled.
I guess I could even do with an ssh option to write a file called ~/bar
at logon, but a more volatile solution would be better.
Calling wget http://.../bar
at logon would be unacceptable.
Any ideas?
P.S. Putty-specific solutions, though I doubt any would exist, are also fine.
Edit: The reason I don't want wget and other file-based solutions is that I don't want to leave a mark since sometimes I connect as other people's users or root. I also don't want every server I connect to making an HTTP request. I want this to have as little overhead as possible.
All the machines in question seem to have
AcceptEnv = LANG LC_*
which means I might have to use a hack like usingLC_BAR
instead ofBAR
.LocalCommand
seems to be configured locally and I was able to execute anecho
, but I don't know how to export an environment variable (or two) from there.export x=y
didn't work. – aib – 2011-02-28T12:12:22.337BTW LocalCommand worked exactly like how you thought
RemoteCommand
would. – aib – 2011-02-28T12:13:44.647@aib, So this means LocalCommand is executed before the shell starts, or as a sub-shell. Bugger. Not sure how to get beyond this. You could probably get LocalCommand to create a file with your script then, can you? – asoundmove – 2011-02-28T12:32:18.777
I see. I was hoping I was doing something wrong, such as not giving the --really-really parameter to export. I guess it has to be a file, then? I'll have to leave a mark on every server I connect to? – aib – 2011-03-01T09:33:38.463