I'm currently working on a #script to run after login, which does the following:
1. Bring down WiFi interface
2. Spoof MAC
3. Generate random word
4. Change hostname to random word
3. Bring up WiFi interface
4. Connect to VPN
Currently written in Bash, but despite the hostname changing successfully when the script runs, running 'hostname' afterwards outputs default hostname...
This all can be done in bash much simplier than python (and faster too), so my guess is bash
Thanks, it seems to work well in Bash now. My mistake was not adding permission to execute script, removing sudo from commands and then just executing whole script as sudo. Just need to get the random hostname generation ironed out now.
I'd normally say Bash, but in your case I'm gonna say both.
Use the best tool for the task
Bash has fewer dependencies and is available on all #Linux boxes and it sounds like this can reasonably be done in bash.
Doing it (also) in Python is a good exercise and allows you to determine (for yourself) which is the better tool for this task.
Bash. Very little need to drag along Python for a simple script, IMO. The bonus is that your script will still work in five years, unlike anything written today in Python.
I presume you changed your /etc/hosts and restarted any services that might have initialized with the old host name?
Currently I'm running 'nmcli general hostname' to change it, which seems to do the trick. I'm using nmcli for all the networking changes. Just need to figure out if I can have my password in a file rather than have it in the script ('nmcli connect <BSSID> password <password>'). Failing that I suppose I could pass it as a silent argument.