The Elusive Command Alias Function? 114
Meph_the_Balrog asks: "I work as a helpdesk jockey for a company that manages over 1200 linux based servers, across a huge area. Currently we use a Windows SSH client to provide remote server support, and I don't have the weight to convince management to deploy alias scripts to all of the servers we support. I admit this question may seem frivolous to some, perhaps dangerous to others, so I have a twofold question. Do any of you out there use a Windows based SSH client that supports command aliasing? If you have strong objections to this sort of technology, what inherent problems do you see with it?"
what are you asking? (Score:3, Informative)
ruptime=`ssh $1 '/bin/uptime'`
Then when you want to check the uptime on a remote box, you run:
ruptime remote_host
And do all this from a Windows box?
If that's the case, you should use Putty. The Putty configuration can be set up to run a remote command, linked to a given hostname. Then when you open Putty, just select the proper 'alias' from the list, just like you would any host.
I would expect SecureCRT has a similar function, but I haven't used it in a few years.
Re:what are you asking? (Score:3, Informative)
When you're editing the properties of a session, you can check the "Logon script" box and choose a logon script to use for that session. You can do that either per-session, or as a global setting so it happens for all of your sessions.
Your logon script can contain as many aliases as you'd like.
I get what he wants. (Score:4, Informative)
He has no power to install his favored command aliases on all of the machine he has to administrate. He wants to have an SSH client (that he can run on Windows to connect to the Linux machines) that will interpret what he types and substitute aliases so that he doesn't have to set up his favored commands every time he logs into a system.
I don't know if you can set an SSH session into a line-based instead of keystroke-based communication mode. By default, it sends messages to the remote server after every keystroke and not after enter is hit at the end of a line -- otherwise using curses-based applications would really, really hurt as would using tab-completion, vi mode, and other advanced shell features. If this can't be done, then a client couldn't interpret your commands before you send them.
I don't forsee anyone providing this functionality because the demand is so low. This is the kind of thing that the remote end is expected to handle for you.
Re:I get what he wants. (Score:3, Informative)
I am all too familiar with his conundrum, especially when it comes to being forced to work with inferior tools. I work in an environment where I am responsible for keeping production systems running, and I don't have admin install privileges. Even our admins don't have the political power to change things without serious peer-review and management approval. This is the way and enterprise-level IT organization has to work. Making changes in production without verification and authorization can result in revenue loss or loss of data that you may one day be required by court to cough up.
Re:Actually it seems like he is looking for is.... (Score:3, Informative)
Re:I get what he wants. (Score:1, Informative)
sh: command line to long
Not that many servers in your data-center, are there?
Try
while read server; do scp
(because I wouldn't want my username duplicated for every server in the serverlist and I tend to avoid using cat without reason).
Why anyone would use bash though is beyond me. My advice: Use something that you know will always be available by default, not something mostly used by Linux-users.