14

I had this script:

spd-say "Hello, don't forget the trash bin."

So it reminded me of what I supposed to do, and I moved it to /usr/local/bin/ and the command trash pronounced the argument,then I set a crontab job, to make it remind me everyday what I wanted to do. But the crontab didn't work and I couldn't understand why(It does other jobs flawlessly).

Once I saw this message in my terminal:

You have new mail in /var/mail/root

at the end of which this line made me do a bad mistake:

/bin/sh: 1: trash: not found

I know that it was a silly thing to do but I did:

mv /usr/local/bin/trash /bin/sh

thinking that sh is a directory and I should move the script there in order to be executed.

Now, when I want to see a man page the system says:

"Hello, don't forget the trash bin."

And the output of cat sh is:

#!/bin/bash
spd-say "Hello, don't forget the trash bin. "

Anyway, can I do anything or I have to reinstall my operating system?

  • 2
    I'm speculating, but cron jobs run with a very limited environment, including a $PATH with just a few directories. That might be why it works from the terminal, but not through cron. (In fact, when something works from a normal terminal but not through cron, that's the first thing I check.) – user Jul 14 '19 at 10:43
  • 1
    @ a CVn; I don't know what the problem is but when I replace *spd-say* by *echo* and set the crontab job: trash > ~/Desktop/trash.txt**, it works & a file is created on my Desktop. I think I should ask about it in another question. –  Jul 14 '19 at 18:17
  • Yes, if you want to ask about that, please do ask it as a separate question. – user Jul 14 '19 at 18:19
  • *'Now, when I want to see a man page the system says: "Hello, don't forget the trash bin."'* To be fair, most `man` docs are rubbish (or difficult to understand) – Malekai Jul 14 '19 at 18:46
  • 8
    @LogicalBranch I disagree; I love them;they're powerful, off-line guides. –  Jul 14 '19 at 18:47
  • @Coditoergosum I intended for my comment to be a pun *(trash bin/rubbish...)*. `man` docs can be quite useful but only if you're not a complete beginner (I speak from personal experience) which is why I wrote that. – Malekai Jul 14 '19 at 18:50

2 Answers2

30

In Ubuntu systems, /bin/sh is a symbolic link to the dash shell by default:

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Jul  7  2018 /bin/sh -> dash

So (assuming your terminal emulator uses the bash shell, and didn't get broken by your mistake) all you need to do is re-create the link:

sudo ln -sf dash /bin/sh
steeldriver
  • 131,985
  • 21
  • 239
  • 326
7

No, you don't have to reinstall your system. /bin/sh is only a softlink to your shell. readlink -f /bin/sh /bin/bash In my case bash. Move your script and make a softlink to your favorite shell.

wjandrea
  • 14,109
  • 4
  • 48
  • 98
nobody
  • 5,149
  • 5
  • 22
  • 43
  • 10
    /bin/sh should actually point to /bin/dash. If you want to change the system shell, use `sudo dpkg-reconfigure dash`, per [How Can I Make /bin/sh point to /bin/bash?](https://askubuntu.com/q/1064773/301745). Also note the system shell is not the default interactive shell. – wjandrea Jul 14 '19 at 19:43