simple alias question

simple alias question

Post by Dan » Sun, 31 Dec 1899 09:00:00



Hi everyone,

I'm running bash, and I want to know how to make simple alias', for
instance if I wanted to telnet into a server, instead of typing 'telnet
somebox.somehost.com' I can just type 'telnet somebox' where somebox is
equivalence to somebox.somehost.com.  I would assume I have to set the
alias in the '.bashrc' what exactly is it that I would have to put
there?

Dan

 
 
 

simple alias question

Post by José Luis Domingo Lóp » Sun, 31 Dec 1899 09:00:00


El da Sun, 26 Nov 2000 16:38:23 -0500,

Quote:> Hi everyone,

> I'm running bash, and I want to know how to make simple alias', for
> instance if I wanted to telnet into a server, instead of typing 'telnet
> somebox.somehost.com' I can just type 'telnet somebox' where somebox is
> equivalence to somebox.somehost.com.  I would assume I have to set the
> alias in the '.bashrc' what exactly is it that I would have to put
> there?

> Dan

Try inserting a static hostname/IP association in your /etc/hosts file.
The syntaxis is as follows:
192.168.1.10    machina.domain.you    alias1   alias2   alias3

--
Jos Luis Domingo Lpez
Linux Registered User #189436     Debian GNU/Linux Potato (P166 64 MB RAM)

jdomingo EN internautas PUNTO org  => ? Spam ? Atente a las consecuencias
jdomingo AT internautas DOT   org  => Spam at your own risk

 
 
 

simple alias question

Post by Floyd Davidso » Sun, 31 Dec 1899 09:00:00



>Hi everyone,

>I'm running bash, and I want to know how to make simple alias', for
>instance if I wanted to telnet into a server, instead of typing 'telnet
>somebox.somehost.com' I can just type 'telnet somebox' where somebox is
>equivalence to somebox.somehost.com.  I would assume I have to set the
>alias in the '.bashrc' what exactly is it that I would have to put
>there?

There are several different things to which the term "alias" is
applied.  There can be email aliases for example, where email
addressed to a given name is delivered to a userid with another
name.

What you are describing is an alias for a given IP address, whereby
it has more than one host name.  That kind of alias can be made by
making an entry in the /etc/hosts file, and making sure that your
system will look in that file before going to a name server.  Your
/etc/host.conf file should have:

  order hosts bind
  multi on

in it.  The first line is important, and the words must be in that
sequence.  Then in /etc/hosts you need an entry that reads something
like this

  192.168.0.2  somebox.somehost.com somebox

Where the "192.168.0.2" is replaced with the actual IP address
of the host you are naming.  (There can be more than just two
names, too.)

Another alias you might consider is the command alias for bash.
That is the kind that goes into ~/.bashrc and can invoke a long
command line with a single short command.  For example, you might
have this in your ~/.bashrc file

  alias ts='telnet somebox.somehost.com'

And from that time on you can just enter "ts" instead of the
entire command line.  If you do that often, "ts" is a good
name.  Try to use one letter alias for things you do *very*
often, two letter commands for things done often, three letters
for common commands, and four or more for things that you'll
never remember the name from one time to the next unless it
says exactly what it is.

--

Ukpeagvik (Barrow, Alaska)

 
 
 

simple alias question

Post by Sebastian Han » Sun, 31 Dec 1899 09:00:00



> Another alias you might consider is the command alias for bash.
> That is the kind that goes into ~/.bashrc and can invoke a long
> command line with a single short command.  For example, you might
> have this in your ~/.bashrc file

>   alias ts='telnet somebox.somehost.com'

> And from that time on you can just enter "ts" instead of the
> entire command line.  If you do that often, "ts" is a good
> name.  Try to use one letter alias for things you do *very*
> often, two letter commands for things done often, three letters
> for common commands, and four or more for things that you'll
> never remember the name from one time to the next unless it
> says exactly what it is.

I'd like to add this:
There is no way for a bash alias to accept command line parameters.
If you want to say something like "dosomethingwith something", you can
create a function like this:
function dosomethingwith {
    # command line paramteres are available as $1, $2 ... so you can do
    # very complicated stuff here

Quote:}

HTH
seb

--
   -------------------=====#####OOOOOOOO#####=====----c---c----------

student of comp sci - technical university of munich  \-^-/  ...just RUN
i'm a .signature virus! copy me into your ~/.signature to help me spread

 
 
 

simple alias question

Post by Wayne Polloc » Sun, 31 Dec 1899 09:00:00


To use the unqualified DNS name "somebox" and have the system look for
"somebox.somehost.com" you must tell the resolver which domain(s) to
search in by default.  This is set in the file /etc/resolv.conf by
adding the line "search somehost.com".  Note up to six domains may
be listed, separated by a space.

The syntax of this file is very strict, make sure your directives
start in column one and that a single space (not tab) is used between
the domains.

Note this is not an alias at all.  You can't make an alias that
has more than one word.  If you really want an alias (which does
indeed go in the .bashrc file), you can use something like this:
        alias somebox='telnet somebox.somehost.com'
or
        alias telnet_somebox='telnet somebox.somehost.com'

-Wayne Pollock


> Hi everyone,

> I'm running bash, and I want to know how to make simple alias', for
> instance if I wanted to telnet into a server, instead of typing 'telnet
> somebox.somehost.com' I can just type 'telnet somebox' where somebox is
> equivalence to somebox.somehost.com.  I would assume I have to set the
> alias in the '.bashrc' what exactly is it that I would have to put
> there?

> Dan

 
 
 

simple alias question

Post by Mark Po » Thu, 30 Nov 2000 11:08:23


On Mon, 27 Nov 2000 14:19:54 +0100, Sebastian Hans



>> Another alias you might consider is the command alias for bash.
>> That is the kind that goes into ~/.bashrc and can invoke a long
>> command line with a single short command.  For example, you might
>> have this in your ~/.bashrc file

>>   alias ts='telnet somebox.somehost.com'

-snip-
>I'd like to add this:
>There is no way for a bash alias to accept command line parameters.

If I'm understanding what you're saying, then I have to disagree with this
statement.  I have a SuSE Linux/390 system at work that has various aliases
for the 'ls' command.  One of them is 'll = ls -l'.  I can still do 'll -tr'
which is the equivalent of 'ls -ltr'.  Are these the kind of command line
parameters you say won't work?  Or were you referring to something else?

Mark Post

Postmodern Consulting
Information Technology and Systems Management Consulting
To send me email, replace 'nospam' with 'home'.

 
 
 

simple alias question

Post by Sebastian Han » Thu, 30 Nov 2000 16:13:42



> >There is no way for a bash alias to accept command line parameters.

> If I'm understanding what you're saying, then I have to disagree with this
> statement.  I have a SuSE Linux/390 system at work that has various aliases
> for the 'ls' command.  One of them is 'll = ls -l'.  I can still do 'll -tr'
> which is the equivalent of 'ls -ltr'.  Are these the kind of command line
> parameters you say won't work?  Or were you referring to something else?

I forgot to say, this depends on where you want to put the command line
parameters. You can do your "ll -tr" because this expands to
"ls -l -tr". What you cannot do is create an alias like
"grepmytexts = grep /very/complex/path" and expect a "grepmytexts foo"
to grep for foo in your files. I't will expand to
"grep /very/complex/path foo" and, of course, that's not what you
intended. That's when you need functions. You'd do this like this:

function grepmytexts {
    grep "$1" /very/complex/path

Quote:}

HTH.
seb

--
   -------------------=====#####OOOOOOOO#####=====----c---c----------

student of comp sci - technical university of munich  \-^-/  ...just RUN
i'm a .signature virus! copy me into your ~/.signature to help me spread

 
 
 

1. Simple alias question

I'm trying to set up an alias for a command that renames a specified file
to today's date. The command is:

        mv file.txt `date '+%m.%d.%y'`

When used at the command prompt, this command works fine. It renames the
file "file.txt" to "05.26.96" (or whatever today's date is). I tried to
set up an alias for this command in ksh, by adding the following line to
my .profile file:

        alias mvtodate="mv $1 `date '+%m.%d.%y'`"

However, when I try to run this command through the alias by typing:

        mvtodate file.txt

I get the following response:

        "Cannot rename 05.26.96 to file.txt: A file or directory in the
         path name does not exist".

Apparently, it's trying to do the reverse of what I want it to do. It's
generating today's date, then looking for a file with that name to move to
file.txt.

Could someone tell me what I'm doing wrong?

Thanks.

------------------------------------------------------------------------



------------------------------------------------------------------------

2. Why not use PS/2 mouse all the time?

3. simple bash alias expansion question

4. Need large uid? Can it be done?

5. Simple Korn Shell alias question

6. tty question

7. Simple question re. shell aliases

8. small drive to big

9. simple question: bash aliases and functions in X

10. Sendmail Aliasing Question - Hopefully Simple

11. Sendmail aliasing question - Hopefully simple

12. aliases, aliases, aliases...

13. script alias problem - Re: apache alias and script alias problem