I'm trying to adapt a script in backtrack to work with ubuntu. I keep getting an error on line 14 which is the "if [ $? == 0 ]; then" line
the script was found on http://pctechtips.org/script-to-change-mac-and-hostname-in-backtrack/
the code is below
#!/bin/bash
#author: Jorge L. Vazquez
#purpose: this script will change the mac address to random
#and will pick a random word from password.lst in jtr for hostname
#change variables "interface" and "file" to your settings
#also macchanger needs to be installed
INTERFACE=eth0
FILE=/pentest/passwords/jtr/password.lst
WORD=$(sort -R $FILE | head -1)
#changing mac address to random
ifconfig $INTERFACE down > /dev/null
if [ $? == 0 ]; then
printf "%s\nChanging mac address...\n"
macchanger -r $INTERFACE
else
printf "%sScript encounter an error, sorry...\n"
exit 1
fi
#changing hostname to random word from password.lst
printf "%s\nChanging Hostname...\n"
OLDHOST=$(hostname)
hostname $WORD
if [ $? == 0 ]; then
printf "%sPrevius Hostname: $OLDHOST \n"
printf "%sRandom Hostname: $WORD \n"
else
printf "%sScript encounter an error, sorry...\n"
exit 1
fi
#putting interface up
ifconfig $INTERFACE up > /dev/null
printf "\n"
#END
And the wordlist file for the hostfile (password.lst) looks like this
# A couple of merged /etc/hosts files --
#
4000ex
a-lhi-bbn-01
a-lhi-sri-03
a00
a1
a2
I run the script using sh filename.sh and i've given it executable access and macchanger is installed but I still get an error