eval ssh command in variable

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I am trying to execute commands via ssh remotely. But I have the calling command saved as variable such as:



SSH_CMD="ssh -i path_to/identity"
SSH_USER=user
SSH_DST=server
dir1=dir1
dir2=dir2


now if I



eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


I get errors (they are typically: mv: cannot stat 'dir1': No such file or directory)



but if I:



ssh -i path_to/identity $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


That works. So the problem seems in how I am handling eval. What is the correct way?










share|improve this question



















  • 1





    Related, if not a dupe: How can we run a command stored in a variable?

    – Kusalananda
    Feb 21 at 18:11











  • Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

    – glenn jackman
    Feb 21 at 18:14











  • @glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

    – leosenko
    Feb 21 at 18:17






  • 1





    That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

    – glenn jackman
    Feb 21 at 18:20






  • 1





    @leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

    – Kusalananda
    Feb 21 at 18:33
















0















I am trying to execute commands via ssh remotely. But I have the calling command saved as variable such as:



SSH_CMD="ssh -i path_to/identity"
SSH_USER=user
SSH_DST=server
dir1=dir1
dir2=dir2


now if I



eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


I get errors (they are typically: mv: cannot stat 'dir1': No such file or directory)



but if I:



ssh -i path_to/identity $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


That works. So the problem seems in how I am handling eval. What is the correct way?










share|improve this question



















  • 1





    Related, if not a dupe: How can we run a command stored in a variable?

    – Kusalananda
    Feb 21 at 18:11











  • Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

    – glenn jackman
    Feb 21 at 18:14











  • @glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

    – leosenko
    Feb 21 at 18:17






  • 1





    That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

    – glenn jackman
    Feb 21 at 18:20






  • 1





    @leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

    – Kusalananda
    Feb 21 at 18:33














0












0








0








I am trying to execute commands via ssh remotely. But I have the calling command saved as variable such as:



SSH_CMD="ssh -i path_to/identity"
SSH_USER=user
SSH_DST=server
dir1=dir1
dir2=dir2


now if I



eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


I get errors (they are typically: mv: cannot stat 'dir1': No such file or directory)



but if I:



ssh -i path_to/identity $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


That works. So the problem seems in how I am handling eval. What is the correct way?










share|improve this question
















I am trying to execute commands via ssh remotely. But I have the calling command saved as variable such as:



SSH_CMD="ssh -i path_to/identity"
SSH_USER=user
SSH_DST=server
dir1=dir1
dir2=dir2


now if I



eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


I get errors (they are typically: mv: cannot stat 'dir1': No such file or directory)



but if I:



ssh -i path_to/identity $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


That works. So the problem seems in how I am handling eval. What is the correct way?







bash ssh eval






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 at 18:13







leosenko

















asked Feb 21 at 18:06









leosenkoleosenko

1798




1798







  • 1





    Related, if not a dupe: How can we run a command stored in a variable?

    – Kusalananda
    Feb 21 at 18:11











  • Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

    – glenn jackman
    Feb 21 at 18:14











  • @glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

    – leosenko
    Feb 21 at 18:17






  • 1





    That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

    – glenn jackman
    Feb 21 at 18:20






  • 1





    @leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

    – Kusalananda
    Feb 21 at 18:33













  • 1





    Related, if not a dupe: How can we run a command stored in a variable?

    – Kusalananda
    Feb 21 at 18:11











  • Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

    – glenn jackman
    Feb 21 at 18:14











  • @glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

    – leosenko
    Feb 21 at 18:17






  • 1





    That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

    – glenn jackman
    Feb 21 at 18:20






  • 1





    @leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

    – Kusalananda
    Feb 21 at 18:33








1




1





Related, if not a dupe: How can we run a command stored in a variable?

– Kusalananda
Feb 21 at 18:11





Related, if not a dupe: How can we run a command stored in a variable?

– Kusalananda
Feb 21 at 18:11













Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

– glenn jackman
Feb 21 at 18:14





Reading material: I'm trying to put a command in a variable, but the complex cases always fail!

– glenn jackman
Feb 21 at 18:14













@glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

– leosenko
Feb 21 at 18:17





@glennjackman I quite disagree with that, the name of an executable can be variable (system to system different) and being able to abstract it is quite important

– leosenko
Feb 21 at 18:17




1




1





That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

– glenn jackman
Feb 21 at 18:20





That's what the $PATH variable is for, so you can specify the "ssh" command you want to use. Or are you saying that on system1, it's called "ssh" and on system2 it has a different name like "secure_shell"?

– glenn jackman
Feb 21 at 18:20




1




1





@leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

– Kusalananda
Feb 21 at 18:33






@leosenko Yes the name of a command. Which variable in your code contains the name of a command? Note that SSH_CMD contains options too, and relies on the shell to do the word-splitting and filename globbing without messing it up.

– Kusalananda
Feb 21 at 18:33











2 Answers
2






active

oldest

votes


















3














eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


This is practically the same as running



eval "$SSH_CMD $SSH_USER@$SSH_DST mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


eval joins the arguments it gets to a single string, and then runs that as shell command. In particular, the && acts on the local side, so the shell runs first ssh ... mkdir dir1, and if that succeeds, it runs mv dir1 dir2, etc. mkdir runs on the remote host, but mv on the local host, where dir1 doesn't exist.




There's no need to use eval here. Your first command would do without it:



$SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


When $SSH_CMD is not quoted, it gets split to the three words ssh, -i, and path_to/identity just as you want. This works, but is somewhat unclean, and you'd get into trouble if you had to include arguments with whitespace within $SSH_CMD, or used glob characters there.



If you need to store a variable number of command arguments, like in SSH_CMD, it's better to use an array. Also, quote the other variables to prevent word splitting, too:



ssh_cmd=(ssh -i path_to/identity)
ssh_user=user
ssh_host=server
dir1=dir1
dir2=dir2
"$ssh_cmd[@]" "$ssh_user@$ssh_host" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


See BashFAQ 050: I'm trying to put a command in a variable, but the complex cases always fail! and How can we run a command stored in a variable? for more details.






share|improve this answer
































    2














    I see no reason to use eval here, it's simply introducing the potential for many vulnerabilities into your command.



    You should store options in an array when possible instead of a variable like so:



    SSH_OPTS=( -i path_to/identity )
    SSH_USER=user
    SSH_DST=server
    dir1=dir1
    dir2=dir2



    Then you should ensure to always double quote your variables:



    ssh "$SSH_OPTS[@]" "$SSH_USER@$SSH_DST" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"





    share|improve this answer




















    • 1





      That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

      – Kusalananda
      Feb 21 at 18:13












    • My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

      – leosenko
      Feb 21 at 18:14











    • @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

      – Jesse_b
      Feb 21 at 18:17










    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',
    autoActivateHeartbeat: false,
    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%2f502141%2feval-ssh-command-in-variable%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


    This is practically the same as running



    eval "$SSH_CMD $SSH_USER@$SSH_DST mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


    eval joins the arguments it gets to a single string, and then runs that as shell command. In particular, the && acts on the local side, so the shell runs first ssh ... mkdir dir1, and if that succeeds, it runs mv dir1 dir2, etc. mkdir runs on the remote host, but mv on the local host, where dir1 doesn't exist.




    There's no need to use eval here. Your first command would do without it:



    $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


    When $SSH_CMD is not quoted, it gets split to the three words ssh, -i, and path_to/identity just as you want. This works, but is somewhat unclean, and you'd get into trouble if you had to include arguments with whitespace within $SSH_CMD, or used glob characters there.



    If you need to store a variable number of command arguments, like in SSH_CMD, it's better to use an array. Also, quote the other variables to prevent word splitting, too:



    ssh_cmd=(ssh -i path_to/identity)
    ssh_user=user
    ssh_host=server
    dir1=dir1
    dir2=dir2
    "$ssh_cmd[@]" "$ssh_user@$ssh_host" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


    See BashFAQ 050: I'm trying to put a command in a variable, but the complex cases always fail! and How can we run a command stored in a variable? for more details.






    share|improve this answer





























      3














      eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


      This is practically the same as running



      eval "$SSH_CMD $SSH_USER@$SSH_DST mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


      eval joins the arguments it gets to a single string, and then runs that as shell command. In particular, the && acts on the local side, so the shell runs first ssh ... mkdir dir1, and if that succeeds, it runs mv dir1 dir2, etc. mkdir runs on the remote host, but mv on the local host, where dir1 doesn't exist.




      There's no need to use eval here. Your first command would do without it:



      $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


      When $SSH_CMD is not quoted, it gets split to the three words ssh, -i, and path_to/identity just as you want. This works, but is somewhat unclean, and you'd get into trouble if you had to include arguments with whitespace within $SSH_CMD, or used glob characters there.



      If you need to store a variable number of command arguments, like in SSH_CMD, it's better to use an array. Also, quote the other variables to prevent word splitting, too:



      ssh_cmd=(ssh -i path_to/identity)
      ssh_user=user
      ssh_host=server
      dir1=dir1
      dir2=dir2
      "$ssh_cmd[@]" "$ssh_user@$ssh_host" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


      See BashFAQ 050: I'm trying to put a command in a variable, but the complex cases always fail! and How can we run a command stored in a variable? for more details.






      share|improve this answer



























        3












        3








        3







        eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        This is practically the same as running



        eval "$SSH_CMD $SSH_USER@$SSH_DST mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        eval joins the arguments it gets to a single string, and then runs that as shell command. In particular, the && acts on the local side, so the shell runs first ssh ... mkdir dir1, and if that succeeds, it runs mv dir1 dir2, etc. mkdir runs on the remote host, but mv on the local host, where dir1 doesn't exist.




        There's no need to use eval here. Your first command would do without it:



        $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        When $SSH_CMD is not quoted, it gets split to the three words ssh, -i, and path_to/identity just as you want. This works, but is somewhat unclean, and you'd get into trouble if you had to include arguments with whitespace within $SSH_CMD, or used glob characters there.



        If you need to store a variable number of command arguments, like in SSH_CMD, it's better to use an array. Also, quote the other variables to prevent word splitting, too:



        ssh_cmd=(ssh -i path_to/identity)
        ssh_user=user
        ssh_host=server
        dir1=dir1
        dir2=dir2
        "$ssh_cmd[@]" "$ssh_user@$ssh_host" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        See BashFAQ 050: I'm trying to put a command in a variable, but the complex cases always fail! and How can we run a command stored in a variable? for more details.






        share|improve this answer















        eval $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        This is practically the same as running



        eval "$SSH_CMD $SSH_USER@$SSH_DST mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        eval joins the arguments it gets to a single string, and then runs that as shell command. In particular, the && acts on the local side, so the shell runs first ssh ... mkdir dir1, and if that succeeds, it runs mv dir1 dir2, etc. mkdir runs on the remote host, but mv on the local host, where dir1 doesn't exist.




        There's no need to use eval here. Your first command would do without it:



        $SSH_CMD $SSH_USER@$SSH_DST "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        When $SSH_CMD is not quoted, it gets split to the three words ssh, -i, and path_to/identity just as you want. This works, but is somewhat unclean, and you'd get into trouble if you had to include arguments with whitespace within $SSH_CMD, or used glob characters there.



        If you need to store a variable number of command arguments, like in SSH_CMD, it's better to use an array. Also, quote the other variables to prevent word splitting, too:



        ssh_cmd=(ssh -i path_to/identity)
        ssh_user=user
        ssh_host=server
        dir1=dir1
        dir2=dir2
        "$ssh_cmd[@]" "$ssh_user@$ssh_host" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"


        See BashFAQ 050: I'm trying to put a command in a variable, but the complex cases always fail! and How can we run a command stored in a variable? for more details.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 21 at 18:26

























        answered Feb 21 at 18:14









        ilkkachuilkkachu

        61.6k10101177




        61.6k10101177























            2














            I see no reason to use eval here, it's simply introducing the potential for many vulnerabilities into your command.



            You should store options in an array when possible instead of a variable like so:



            SSH_OPTS=( -i path_to/identity )
            SSH_USER=user
            SSH_DST=server
            dir1=dir1
            dir2=dir2



            Then you should ensure to always double quote your variables:



            ssh "$SSH_OPTS[@]" "$SSH_USER@$SSH_DST" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"





            share|improve this answer




















            • 1





              That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

              – Kusalananda
              Feb 21 at 18:13












            • My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

              – leosenko
              Feb 21 at 18:14











            • @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

              – Jesse_b
              Feb 21 at 18:17















            2














            I see no reason to use eval here, it's simply introducing the potential for many vulnerabilities into your command.



            You should store options in an array when possible instead of a variable like so:



            SSH_OPTS=( -i path_to/identity )
            SSH_USER=user
            SSH_DST=server
            dir1=dir1
            dir2=dir2



            Then you should ensure to always double quote your variables:



            ssh "$SSH_OPTS[@]" "$SSH_USER@$SSH_DST" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"





            share|improve this answer




















            • 1





              That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

              – Kusalananda
              Feb 21 at 18:13












            • My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

              – leosenko
              Feb 21 at 18:14











            • @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

              – Jesse_b
              Feb 21 at 18:17













            2












            2








            2







            I see no reason to use eval here, it's simply introducing the potential for many vulnerabilities into your command.



            You should store options in an array when possible instead of a variable like so:



            SSH_OPTS=( -i path_to/identity )
            SSH_USER=user
            SSH_DST=server
            dir1=dir1
            dir2=dir2



            Then you should ensure to always double quote your variables:



            ssh "$SSH_OPTS[@]" "$SSH_USER@$SSH_DST" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"





            share|improve this answer















            I see no reason to use eval here, it's simply introducing the potential for many vulnerabilities into your command.



            You should store options in an array when possible instead of a variable like so:



            SSH_OPTS=( -i path_to/identity )
            SSH_USER=user
            SSH_DST=server
            dir1=dir1
            dir2=dir2



            Then you should ensure to always double quote your variables:



            ssh "$SSH_OPTS[@]" "$SSH_USER@$SSH_DST" "mkdir $dir1 && mv $dir1 $dir2 && touch $dir2"






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 21 at 18:15

























            answered Feb 21 at 18:10









            Jesse_bJesse_b

            13.7k23471




            13.7k23471







            • 1





              That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

              – Kusalananda
              Feb 21 at 18:13












            • My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

              – leosenko
              Feb 21 at 18:14











            • @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

              – Jesse_b
              Feb 21 at 18:17












            • 1





              That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

              – Kusalananda
              Feb 21 at 18:13












            • My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

              – leosenko
              Feb 21 at 18:14











            • @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

              – Jesse_b
              Feb 21 at 18:17







            1




            1





            That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

            – Kusalananda
            Feb 21 at 18:13






            That last bit, if it was sourced or executed by a shell (it's not clear in the question) it would try to run -i as a command. And now it's updated in the question.

            – Kusalananda
            Feb 21 at 18:13














            My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

            – leosenko
            Feb 21 at 18:14





            My bad, the SSH_COMMAND is quoted, see the edit. I apologize. What would be the more general case if I wanted to keep the name ssh stored in a variable as well?

            – leosenko
            Feb 21 at 18:14













            @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

            – Jesse_b
            Feb 21 at 18:17





            @leosenko: The only reason I could think of to store the ssh command in a variable would be to specify the full path and ensure you are using a specific version of a command. However you can just add it into the beginning of the SSH_OPTS array if you desire. I would consider that obfuscated.

            – Jesse_b
            Feb 21 at 18:17

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502141%2feval-ssh-command-in-variable%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?