Creating alias failing in bashrc using function method
up vote
-1
down vote
favorite
I am trying to create alias in bashrc
using function method as I need to pass argument while executing.
Here i have created alias.
login-lnx1 () { 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2'; }
Here is output after execution.
bash-3.2$ login-lnx1 3001
bash: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2: No such file or directory
function bourne-shell
add a comment |
up vote
-1
down vote
favorite
I am trying to create alias in bashrc
using function method as I need to pass argument while executing.
Here i have created alias.
login-lnx1 () { 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2'; }
Here is output after execution.
bash-3.2$ login-lnx1 3001
bash: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2: No such file or directory
function bourne-shell
2
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am trying to create alias in bashrc
using function method as I need to pass argument while executing.
Here i have created alias.
login-lnx1 () { 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2'; }
Here is output after execution.
bash-3.2$ login-lnx1 3001
bash: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2: No such file or directory
function bourne-shell
I am trying to create alias in bashrc
using function method as I need to pass argument while executing.
Here i have created alias.
login-lnx1 () { 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2'; }
Here is output after execution.
bash-3.2$ login-lnx1 3001
bash: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2: No such file or directory
function bourne-shell
function bourne-shell
edited Nov 20 at 22:46
Rui F Ribeiro
38.2k1475125
38.2k1475125
asked Jan 13 '17 at 18:33
hafiz
1
1
2
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00
add a comment |
2
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00
2
2
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
Just remove the single quotes in your function (this is not an alias):
login-lnx1 () { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2; }
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Just remove the single quotes in your function (this is not an alias):
login-lnx1 () { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2; }
add a comment |
up vote
3
down vote
Just remove the single quotes in your function (this is not an alias):
login-lnx1 () { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2; }
add a comment |
up vote
3
down vote
up vote
3
down vote
Just remove the single quotes in your function (this is not an alias):
login-lnx1 () { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2; }
Just remove the single quotes in your function (this is not an alias):
login-lnx1 () { ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p "$1" -l username lnx2; }
answered Jan 13 '17 at 18:57
xhienne
11.9k2554
11.9k2554
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f337207%2fcreating-alias-failing-in-bashrc-using-function-method%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
As @xhienne says in his answer, functions are not aliases, so there isn't a "function method" to create an alias. You either create a function or an alias, they're different things.
– Eric Renouf
Jan 13 '17 at 19:00