perl - Macxchange Script to Change MAC and Hostname in ubuntu 12.04 -
i'm trying adapt script in backtrack work ubuntu. keep getting error on line 14 if [ $? == 0 ]; then
line.
the script found on http://pctechtips.org/script-to-change-mac-and-hostname-in-backtrack/
the code below:
#!/bin/bash #author: jorge l. vazquez #purpose: script change mac address random #and pick random word password.lst in jtr hostname #change variables "interface" , "file" settings #also macchanger needs installed interface=eth0 file=/pentest/passwords/jtr/password.lst word=$(sort -r $file | head -1) #changing mac address random ifconfig $interface down > /dev/null if [ $? == 0 ]; printf "%s\nchanging mac address...\n" macchanger -r $interface else printf "%sscript encounter error, sorry...\n" exit 1 fi #changing hostname random word password.lst printf "%s\nchanging hostname...\n" oldhost=$(hostname) hostname $word if [ $? == 0 ]; printf "%sprevius hostname: $oldhost \n" printf "%srandom hostname: $word \n" else printf "%sscript encounter error, sorry...\n" exit 1 fi #putting interface ifconfig $interface > /dev/null printf "\n" #end
and wordlist file hostfile (password.lst) looks this
# couple of merged /etc/hosts files -- # 4000ex a-lhi-bbn-01 a-lhi-sri-03 a00 a1 a2
i run script using sh filename.sh
, i've given executable access , macchanger installed still error 14: [: 0: unexpected operator script encounter error, sorry...
try with
if [ $? = 0 ];
instead. ==
not canonical way write in bash, versions accept it.
don't forget repeat fix @ second occurrence below.
Comments
Post a Comment