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?

How long does it take to type this?

How can I fix this gap between bookcases I made?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

N.B. ligature in Latex

If Manufacturer spice model and Datasheet give different values which should I use?

How is this relation reflexive?

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

"You are your self first supporter", a more proper way to say it

Download, install and reboot computer at night if needed

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

Why don't electron-positron collisions release infinite energy?

Infinite past with a beginning?

Is it possible to do 50 km distance without any previous training?

Validation accuracy vs Testing accuracy

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Banach space and Hilbert space topology

Set-theoretical foundations of Mathematics with only bounded quantifiers

How is it possible for user to changed after storage was encrypted? (on OS X, Android)

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

The use of multiple foreign keys on same column in SQL Server

New order #4: World

How to report a triplet of septets in NMR tabulation?

Is it possible to make sharp wind that can cut stuff from afar?

Why can't I see bouncing of a switch on an oscilloscope?



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 3 hours 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




















          • 3





            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
            3 hours ago







          • 1





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

            – slm
            3 hours ago






          • 1





            @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

            – marcelm
            1 hour ago











          • @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

            – slm
            1 hour ago











          • So what does that trailing asterisk (*) do in bash?

            – user000001
            1 hour 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




















          • 3





            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
            3 hours ago







          • 1





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

            – slm
            3 hours ago






          • 1





            @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

            – marcelm
            1 hour ago











          • @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

            – slm
            1 hour ago











          • So what does that trailing asterisk (*) do in bash?

            – user000001
            1 hour 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




















          • 3





            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
            3 hours ago







          • 1





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

            – slm
            3 hours ago






          • 1





            @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

            – marcelm
            1 hour ago











          • @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

            – slm
            1 hour ago











          • So what does that trailing asterisk (*) do in bash?

            – user000001
            1 hour 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 3 hours ago

























          answered 3 hours ago









          slmslm

          1,87311824




          1,87311824







          • 3





            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
            3 hours ago







          • 1





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

            – slm
            3 hours ago






          • 1





            @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

            – marcelm
            1 hour ago











          • @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

            – slm
            1 hour ago











          • So what does that trailing asterisk (*) do in bash?

            – user000001
            1 hour ago












          • 3





            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
            3 hours ago







          • 1





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

            – slm
            3 hours ago






          • 1





            @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

            – marcelm
            1 hour ago











          • @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

            – slm
            1 hour ago











          • So what does that trailing asterisk (*) do in bash?

            – user000001
            1 hour ago







          3




          3





          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
          3 hours 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
          3 hours ago





          1




          1





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

          – slm
          3 hours ago





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

          – slm
          3 hours ago




          1




          1





          @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

          – marcelm
          1 hour ago





          @slm That doesn't make sense... You state in your answer "... since you're expecting Bash features ...", but the OP is clearly not using any bash features in his script. I agree with dessert that the #!/bin/bash advice is misplaced. It's the "also" part of your answer that is the actual answer ;)

          – marcelm
          1 hour ago













          @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

          – slm
          1 hour ago





          @marcelm - as I stated to dessert above, if someone is attempting to use the features of something, better to use it directly vs. indirectly. I'm not saying that the OP was actually using any Bash features per say, just that they're writing a Bash script so call it out directly vs. sh.

          – slm
          1 hour ago













          So what does that trailing asterisk (*) do in bash?

          – user000001
          1 hour ago





          So what does that trailing asterisk (*) do in bash?

          – user000001
          1 hour 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

          How to create a command for the “strange m” symbol in latex? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do you make your own symbol when Detexify fails?Writing bold small caps with mathpazo packageplus-minus symbol with parenthesis around the minus signGreek character in Beamer document titleHow to create dashed right arrow over symbol?Currency symbol: Turkish LiraDouble prec as a single symbol?Plus Sign Too Big; How to Call adfbullet?Is there a TeX macro for three-legged pi?How do I get my integral-like symbol to align like the integral?How to selectively substitute a letter with another symbol representing the same letterHow do I generate a less than symbol and vertical bar that are the same height?

          Българска екзархия Съдържание История | Български екзарси | Вижте също | Външни препратки | Литература | Бележки | НавигацияУстав за управлението на българската екзархия. Цариград, 1870Слово на Ловешкия митрополит Иларион при откриването на Българския народен събор в Цариград на 23. II. 1870 г.Българската правда и гръцката кривда. От С. М. (= Софийски Мелетий). Цариград, 1872Предстоятели на Българската екзархияПодмененият ВеликденИнформационна агенция „Фокус“Димитър Ризов. Българите в техните исторически, етнографически и политически граници (Атлас съдържащ 40 карти). Berlin, Königliche Hoflithographie, Hof-Buch- und -Steindruckerei Wilhelm Greve, 1917Report of the International Commission to Inquire into the Causes and Conduct of the Balkan Wars

          Чепеларе Съдържание География | История | Население | Спортни и природни забележителности | Културни и исторически обекти | Религии | Обществени институции | Известни личности | Редовни събития | Галерия | Източници | Литература | Външни препратки | Навигация41°43′23.99″ с. ш. 24°41′09.99″ и. д. / 41.723333° с. ш. 24.686111° и. д.*ЧепелареЧепеларски Linux fest 2002Начало на Зимен сезон 2005/06Национални хайдушки празници „Капитан Петко Войвода“Град ЧепелареЧепеларе – народният ски курортbgrod.orgwww.terranatura.hit.bgСправка за населението на гр. Исперих, общ. Исперих, обл. РазградМузей на родопския карстМузей на спорта и скитеЧепеларебългарскибългарскианглийскитукИстория на градаСки писти в ЧепелареВремето в ЧепелареРадио и телевизия в ЧепелареЧепеларе мами с родопски чар и добри пистиЕвтин туризъм и снежни атракции в ЧепелареМестоположениеИнформация и снимки от музея на родопския карст3D панорами от ЧепелареЧепелареррр