SSH with Command Doesn't Run as an Alias

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











up vote
0
down vote

favorite












I have the following command to remote into a local server and tail -f the latest log file for an application that I have.



The command works perfectly fine from the command line -



ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'



The problem is that when I make it an alias (or even a function), it evaluates the completion of the ls -1r on my local machine and tries to pass that to the remote machine.



alias latestbotlogs="ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"

function latestbotlogs head -1)'



What syntax do I need to use such that the entire command gets evaluated on the remote machine that I am accessing via SSH.



Thanks in advance!









share







New contributor




mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I have the following command to remote into a local server and tail -f the latest log file for an application that I have.



    The command works perfectly fine from the command line -



    ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'



    The problem is that when I make it an alias (or even a function), it evaluates the completion of the ls -1r on my local machine and tries to pass that to the remote machine.



    alias latestbotlogs="ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"

    function latestbotlogs head -1)'



    What syntax do I need to use such that the entire command gets evaluated on the remote machine that I am accessing via SSH.



    Thanks in advance!









    share







    New contributor




    mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have the following command to remote into a local server and tail -f the latest log file for an application that I have.



      The command works perfectly fine from the command line -



      ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'



      The problem is that when I make it an alias (or even a function), it evaluates the completion of the ls -1r on my local machine and tries to pass that to the remote machine.



      alias latestbotlogs="ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"

      function latestbotlogs head -1)'



      What syntax do I need to use such that the entire command gets evaluated on the remote machine that I am accessing via SSH.



      Thanks in advance!









      share







      New contributor




      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have the following command to remote into a local server and tail -f the latest log file for an application that I have.



      The command works perfectly fine from the command line -



      ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'



      The problem is that when I make it an alias (or even a function), it evaluates the completion of the ls -1r on my local machine and tries to pass that to the remote machine.



      alias latestbotlogs="ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"

      function latestbotlogs head -1)'



      What syntax do I need to use such that the entire command gets evaluated on the remote machine that I am accessing via SSH.



      Thanks in advance!







      bash ssh alias





      share







      New contributor




      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 min ago









      mattdonders

      1012




      1012




      New contributor




      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      mattdonders is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











          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: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          mattdonders is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477802%2fssh-with-command-doesnt-run-as-an-alias%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          mattdonders is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          mattdonders is a new contributor. Be nice, and check out our Code of Conduct.












          mattdonders is a new contributor. Be nice, and check out our Code of Conduct.











          mattdonders is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477802%2fssh-with-command-doesnt-run-as-an-alias%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos