Shell script can be run only with sh commandHow Can I Run an Shell Script With .desktop Config File?Automated Shell script to run fdisk command with user inputcustomized shell script can not be runUnable to Run Shell Script on UbuntuUbuntu Unity 16.10 'sudo: no tty present and no askpass program specified'Can I run shell script together with application?Executable shell script doesn't runShell script for network manager not completingcurl command not executing via shell script in bashHow can I run gsettings from a GNOME Shell Extension?

Why CLRS example on residual networks does not follows its formula?

Email Account under attack (really) - anything I can do?

If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?

What are these boxed doors outside store fronts in New York?

Japan - Plan around max visa duration

How long does it take to type this?

Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?

Copenhagen passport control - US citizen

What is the offset in a seaplane's hull?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

Can I make popcorn with any corn?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

Patience, young "Padovan"

"which" command doesn't work / path of Safari?

Why is an old chain unsafe?

Shell script not opening as desktop application

How do I create uniquely male characters?

How much RAM could one put in a typical 80386 setup?

Disadvantages of online checking accounts?

What do you call a Matrix-like slowdown and camera movement effect?

Can I interfere when another PC is about to be attacked?

What would happen to a modern skyscraper if it rains micro blackholes?

What is the command to reset a PC without deleting any files



Shell script can be run only with sh command


How Can I Run an Shell Script With .desktop Config File?Automated Shell script to run fdisk command with user inputcustomized shell script can not be runUnable to Run Shell Script on UbuntuUbuntu Unity 16.10 'sudo: no tty present and no askpass program specified'Can I run shell script together with application?Executable shell script doesn't runShell script for network manager not completingcurl command not executing via shell script in bashHow can I run gsettings from a GNOME Shell Extension?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a small sh script that I use to backup to a remote server. It worked on Ubuntu 16.04 for years, but now on 18.04 it fails. At first I thought it was a problem with anacron, but now I think it is a problem with the script itself or with dash. Here is what is happening:



stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sudo chmod +x rsync-doc-script 
[sudo] Mot de passe de stefan :
stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ ./rsync-doc-script
/bin/sh: 0: Can't open *
stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sh rsync-doc-script
opening connection using: ssh -i /home/stefan/.ssh/id_rsa -l totem MouseHouse rsync --server -vvlogDtprze.iLsfxC . /totembackup/totemdoc (11 args)
ssh: connect to host mousehouse port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
stefan@stefan-Aspire-F5-573T:/etc/cron.daily$


The error can't open * is preventing the script from running correctly when run by run-parts. Why is this error occurring?



It is not relevant that in the last line, when the script ran, it couldn't establish connection. The server is turned off now.



Here is the script:



#!/bin/sh *
rsync -azvv -e "ssh -i /home/stefan/.ssh/id_rsa" /home/stefan/Documents/ totem@MouseHouse:/totembackup/totemdoc










share|improve this question




























    1















    I have a small sh script that I use to backup to a remote server. It worked on Ubuntu 16.04 for years, but now on 18.04 it fails. At first I thought it was a problem with anacron, but now I think it is a problem with the script itself or with dash. Here is what is happening:



    stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sudo chmod +x rsync-doc-script 
    [sudo] Mot de passe de stefan :
    stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ ./rsync-doc-script
    /bin/sh: 0: Can't open *
    stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sh rsync-doc-script
    opening connection using: ssh -i /home/stefan/.ssh/id_rsa -l totem MouseHouse rsync --server -vvlogDtprze.iLsfxC . /totembackup/totemdoc (11 args)
    ssh: connect to host mousehouse port 22: Connection refused
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
    stefan@stefan-Aspire-F5-573T:/etc/cron.daily$


    The error can't open * is preventing the script from running correctly when run by run-parts. Why is this error occurring?



    It is not relevant that in the last line, when the script ran, it couldn't establish connection. The server is turned off now.



    Here is the script:



    #!/bin/sh *
    rsync -azvv -e "ssh -i /home/stefan/.ssh/id_rsa" /home/stefan/Documents/ totem@MouseHouse:/totembackup/totemdoc










    share|improve this question
























      1












      1








      1








      I have a small sh script that I use to backup to a remote server. It worked on Ubuntu 16.04 for years, but now on 18.04 it fails. At first I thought it was a problem with anacron, but now I think it is a problem with the script itself or with dash. Here is what is happening:



      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sudo chmod +x rsync-doc-script 
      [sudo] Mot de passe de stefan :
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ ./rsync-doc-script
      /bin/sh: 0: Can't open *
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sh rsync-doc-script
      opening connection using: ssh -i /home/stefan/.ssh/id_rsa -l totem MouseHouse rsync --server -vvlogDtprze.iLsfxC . /totembackup/totemdoc (11 args)
      ssh: connect to host mousehouse port 22: Connection refused
      rsync: connection unexpectedly closed (0 bytes received so far) [sender]
      rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$


      The error can't open * is preventing the script from running correctly when run by run-parts. Why is this error occurring?



      It is not relevant that in the last line, when the script ran, it couldn't establish connection. The server is turned off now.



      Here is the script:



      #!/bin/sh *
      rsync -azvv -e "ssh -i /home/stefan/.ssh/id_rsa" /home/stefan/Documents/ totem@MouseHouse:/totembackup/totemdoc










      share|improve this question














      I have a small sh script that I use to backup to a remote server. It worked on Ubuntu 16.04 for years, but now on 18.04 it fails. At first I thought it was a problem with anacron, but now I think it is a problem with the script itself or with dash. Here is what is happening:



      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sudo chmod +x rsync-doc-script 
      [sudo] Mot de passe de stefan :
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ ./rsync-doc-script
      /bin/sh: 0: Can't open *
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$ sh rsync-doc-script
      opening connection using: ssh -i /home/stefan/.ssh/id_rsa -l totem MouseHouse rsync --server -vvlogDtprze.iLsfxC . /totembackup/totemdoc (11 args)
      ssh: connect to host mousehouse port 22: Connection refused
      rsync: connection unexpectedly closed (0 bytes received so far) [sender]
      rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
      stefan@stefan-Aspire-F5-573T:/etc/cron.daily$


      The error can't open * is preventing the script from running correctly when run by run-parts. Why is this error occurring?



      It is not relevant that in the last line, when the script ran, it couldn't establish connection. The server is turned off now.



      Here is the script:



      #!/bin/sh *
      rsync -azvv -e "ssh -i /home/stefan/.ssh/id_rsa" /home/stefan/Documents/ totem@MouseHouse:/totembackup/totemdoc







      bash scripts sh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 42 mins ago









      Stefan DawydiakStefan Dawydiak

      1235




      1235




















          1 Answer
          1






          active

          oldest

          votes


















          5














          I'd switch from using #!/bin/sh as your shebang to #!/bin/bash since you're expecting Bash features vs. /bin/sh or /bin/dash.



          Also I can't tell for sure but it looks like you have a typo on the first line where there's a stray * over to the right.



          #!/bin/sh *


          ^^^ Scroll over to the right to see it.



          Example



          $ cat script.bash
          #!/bin/sh *
          echo hi


          Run directly:



          $ ./script.bash
          /bin/sh: *: No such file or directory


          Run via sh:



          $ sh script.bash
          hi





          share|improve this answer




















          • 2





            Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

            – dessert
            33 mins ago







          • 1





            @dessert - I state that as a general practice, if you expect features from X, use X.

            – slm
            32 mins ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2faskubuntu.com%2fquestions%2f1131967%2fshell-script-can-be-run-only-with-sh-command%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









          5














          I'd switch from using #!/bin/sh as your shebang to #!/bin/bash since you're expecting Bash features vs. /bin/sh or /bin/dash.



          Also I can't tell for sure but it looks like you have a typo on the first line where there's a stray * over to the right.



          #!/bin/sh *


          ^^^ Scroll over to the right to see it.



          Example



          $ cat script.bash
          #!/bin/sh *
          echo hi


          Run directly:



          $ ./script.bash
          /bin/sh: *: No such file or directory


          Run via sh:



          $ sh script.bash
          hi





          share|improve this answer




















          • 2





            Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

            – dessert
            33 mins ago







          • 1





            @dessert - I state that as a general practice, if you expect features from X, use X.

            – slm
            32 mins ago















          5














          I'd switch from using #!/bin/sh as your shebang to #!/bin/bash since you're expecting Bash features vs. /bin/sh or /bin/dash.



          Also I can't tell for sure but it looks like you have a typo on the first line where there's a stray * over to the right.



          #!/bin/sh *


          ^^^ Scroll over to the right to see it.



          Example



          $ cat script.bash
          #!/bin/sh *
          echo hi


          Run directly:



          $ ./script.bash
          /bin/sh: *: No such file or directory


          Run via sh:



          $ sh script.bash
          hi





          share|improve this answer




















          • 2





            Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

            – dessert
            33 mins ago







          • 1





            @dessert - I state that as a general practice, if you expect features from X, use X.

            – slm
            32 mins ago













          5












          5








          5







          I'd switch from using #!/bin/sh as your shebang to #!/bin/bash since you're expecting Bash features vs. /bin/sh or /bin/dash.



          Also I can't tell for sure but it looks like you have a typo on the first line where there's a stray * over to the right.



          #!/bin/sh *


          ^^^ Scroll over to the right to see it.



          Example



          $ cat script.bash
          #!/bin/sh *
          echo hi


          Run directly:



          $ ./script.bash
          /bin/sh: *: No such file or directory


          Run via sh:



          $ sh script.bash
          hi





          share|improve this answer















          I'd switch from using #!/bin/sh as your shebang to #!/bin/bash since you're expecting Bash features vs. /bin/sh or /bin/dash.



          Also I can't tell for sure but it looks like you have a typo on the first line where there's a stray * over to the right.



          #!/bin/sh *


          ^^^ Scroll over to the right to see it.



          Example



          $ cat script.bash
          #!/bin/sh *
          echo hi


          Run directly:



          $ ./script.bash
          /bin/sh: *: No such file or directory


          Run via sh:



          $ sh script.bash
          hi






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 33 mins ago

























          answered 39 mins ago









          slmslm

          1,87111824




          1,87111824







          • 2





            Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

            – dessert
            33 mins ago







          • 1





            @dessert - I state that as a general practice, if you expect features from X, use X.

            – slm
            32 mins ago












          • 2





            Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

            – dessert
            33 mins ago







          • 1





            @dessert - I state that as a general practice, if you expect features from X, use X.

            – slm
            32 mins ago







          2




          2





          Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

          – dessert
          33 mins ago






          Exactly, this asterisk is producing a syntax error when the shebang line is used, thus preventing the script from being run. OP’s script is not using any bash features though, there’s no need to make it #!/bin/bash. A shebang line #!/bin/bash * throws an error as well.

          – dessert
          33 mins ago





          1




          1





          @dessert - I state that as a general practice, if you expect features from X, use X.

          – slm
          32 mins ago





          @dessert - I state that as a general practice, if you expect features from X, use X.

          – slm
          32 mins ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1131967%2fshell-script-can-be-run-only-with-sh-command%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

          बाताम इन्हें भी देखें सन्दर्भ दिक्चालन सूची1°05′00″N 104°02′0″E / 1.08333°N 104.03333°E / 1.08333; 104.033331°05′00″N 104°02′0″E / 1.08333°N 104.03333°E / 1.08333; 104.03333

          Why is the 'in' operator throwing an error with a string literal instead of logging false?Why can't I use switch statement on a String?Python join: why is it string.join(list) instead of list.join(string)?Multiline String Literal in C#Why does comparing strings using either '==' or 'is' sometimes produce a different result?How to initialize an array's length in javascript?How can I print literal curly-brace characters in python string and also use .format on it?Why does ++[[]][+[]]+[+[]] return the string “10”?Why is char[] preferred over String for passwords?Why does this code using random strings print “hello world”?jQuery.inArray(), how to use it right?

          How can we generalize the fact of finite dimensional vector space to an infinte dimensional case?$k[x]$-module and cyclic module over a finite dimensional vector spaceSubspace of a finite dimensional space is finite dimensionalIf V is an infinite-dimensional vector space, and S is an infinite-dimensional subspace of V, must the dimension of V/S be finite? ExplainWhy is an infinite dimensional space so different than a finite dimensional one?base for finite dimensional vector space is not infinite dimensional vector space?Any finite-dimensional vector space is the dual space of anotherHaving Trouble Understanding Meaning Of A Finite-Dimensional Vector SpaceProve that “Every subspaces of a finite-dimensional vector space is finite-dimensional”Ring as a finite dimensional Vector space over a field KQuestion regarding basis and dimension