home | categories | readme


Spending time on the shared Avant Whatever server I'm always fascinated by the conditions of presence.

When I SSH into the server I have a series of commands I'm likely to run. I automated these for a while, but missed the tactility. The simple, fragile, input of commands. It's no doubt different for others, but I often log in simply to run htese commands, moving between a handful of directories. I guess I'm checking in - to see if it is still there - if there really is a tiny server on the other side of the world that I can write to.

Anyway, the following is a directory with a couple of files. Running the switch.py script will re-write the .txt file to be either on or off. A message will print confirming the action. So that's it - a switch.

  ├── off.txt
  ├── readme.txt
  └── switch.py



python switch.py

to toggle the switch.


import os

# Absolute path of a file
old_name = r"on.txt"
new_name = r"off.txt"

success = "You toggled  the switch."

# Renaming the file

if (os.path.exists(old_name)):
  os.rename(old_name, new_name)
	os.rename(new_name, old_name)


This file could contain anything... I think it has to contain at least a thing. Mine has 'o'.

categories: code

~gg 04/23