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









share|improve this question




















  • 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















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









share|improve this question




















  • 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













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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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










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; }





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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; }





    share|improve this answer

























      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; }





      share|improve this answer























        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; }





        share|improve this answer












        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; }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 13 '17 at 18:57









        xhienne

        11.9k2554




        11.9k2554






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre