What’s the difference between running a shell script as ./script.sh and sh script.sh?
00:42 18 Mar 2010

I have a script that looks like this

#!/bin/bash

function something() {
    echo "Hello, World!!!"
}

something | tee logfile

I have set the execute permission on this file and when I try running the file like this

 ./script.sh

It runs perfectly fine, but when I run it on the command line like this

sh script.sh

It throws up an error. Why does this happen and what are the ways in which I can fix this?

unix scripting shell