Code: Select all
#!/bin/bash
# init
echo & echo "(Website):" && read input
output=$(ping -c 1 "$input" 2>/dev/null)
if [ $? -eq 0 ]; then
ip=$(printf '%s' "$output" | gawk -F'[()]' '/PING/{print $2}' 2>/dev/null)
clear
echo
echo "$ip";
echo -n $ip | xclip -selection c
echo
echo IP copied to clipboard.
sleep 2
exit
else
clear
echo "Host not found";
sleep 1
exit
fi
I have not really changed the script, when I was using Linux Mint 14 (cinnamon) this very script worked without issue.
But now, when I open a terminal and type:
Code: Select all
sh ~/Desktop/shell.sh
it returns:
Code: Select all
: not found/Desktop/shell.sh: 3: /home/user/Desktop/shell.sh:
(Website):
It returns:
Code: Select all
: bad variable name/shell.sh: 4: read:
: not found/Desktop/shell.sh: 5: /home/user/Desktop/shell.sh:
/home/user/Desktop/shell.sh: 24: /home/user/Desktop/shell.sh: Syntax error: word unexpected
I don't really understand where this error is coming from. Help is always appreciated.
Thanks in advance