PDA

View Full Version : [ubuntu] whats wrong with this script?



cosmoshell
August 4th, 2009, 06:59 PM
gksudo ifconfig eth0 down & sudo macchanger -r eth0 & sudo ifconfig eth0 up

i want to run this buy clicking on its icon.

credobyte
August 4th, 2009, 07:01 PM
& should be replaced with && and gksudo with sudo:

sudo ifconfig eth0 down && sudo macchanger -r eth0 && sudo ifconfig eth0 up

wizard10000
August 4th, 2009, 07:11 PM
Also, test each command separately in the same terminal window.

'&&' is conditional - it'll only move on to the next command in the string if the previous command returned an exit status of 0.

cosmoshell
August 4th, 2009, 07:12 PM
& should be replaced with && and gksudo with sudo:

sudo ifconfig eth0 down && sudo macchanger -r eth0 && sudo ifconfig eth0 up
strange did it like that before and it dident work. does now tho. thank you

credobyte
August 4th, 2009, 07:13 PM
Also, test each command separately in the same terminal window.

'&&' is conditional - it'll only move on to the next command in the string if the previous command returned an exit status of 0.

Which is pretty much exactly what most of these scripts need. If turning network off fails, changing mac is useless ( not to mention that trying to turn on already running service is impossible ).

achase79
August 4th, 2009, 07:22 PM
using sudo in a script is a bad precident. Executing the script with sudo or gksu is more appropriate.