sh, bash, dash and Ubuntu

Hi!
I wanted to install a quite old package in my ubuntu computer using the .sh file I downloaded from their website. So, I tried typing in terminal:

sudo ./package_name.sh

and I got:

/bin/sh: 0: Can’t open ./package_name.sh

Briliant! Since you are here, you are probably looking for a fix.

The problem stems from the fact that Ubuntu uses dash as the default shell and your script is written with another shell in mind. The most usual is bash (sh).

So type in a terminal window:

sudo bash ./package_name.sh

This will force ubuntu to run the script using bash.

Enjoy!
Vasilis

Bash script for webpage changes monitoring

I wrote a simple bash script for monitoring changes in a webpage. I was able to find a couple or more such scripts on the web but non of those worked for https websites with non-valid cerfificates. So here is one that does:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

while true; do

if [[ -f new_page.html ]]; then
  mv new_page.html old_page.html
fi
wget --tries=45 --wait=10 $1 -O new_page.html --no-check-certificate > /dev/null 2>&1
diff ./new_page.html ./old_page.html > /dev/null
if [[ $? -ne 0 ]]; then
  echo "The webpage has changed!"
  date
  # mpg123 -q /home/user/latin_rhythm_guitar.mp3
  firefox $1
else
  echo "No change"
  date
fi
# sleep some time
sleep 1800
done

The line mpg123 -q /home/user/latin_rhythm_guitar.mp3 is commented out. If you choose to play a song each time a change in the webpage occurs change the filename and un-comment.

Part of the source code is from the script found here.