terminal.py

Created by tlake

Created on August 07, 2024

1.47 KB


#version 1.2.6

"""
instructions supportees :
cd,cat,mv,mkdir,rm,rmdir,touch,pwd,ls,python,clear,su
"""
"""
import time as t
tD=t.monotonic()
"""
print("Initialising file system...")
from FS import *
"""import gc
print("Memory free :",gc.mem_free())
print("Optimising memory...")
gc.collect()
print("Memory free :",gc.mem_free())
print("Ready ! ("+str(round(t.monotonic()-tD,1)),"seconds setup)")
del gc,t,tD
"""
#definitions de variables du terminal
user="user"


#definitions de commandes du terminal

def python(name=""):
  import sys
  l=sys.implementation
  l2=[]
  for i in l[1]:
    l2.append(str(i))
  print(l[0],"version",".".join(l2))
  print("Type exit() to quit.")
  return "python"


def clear():
  import sys
  for i in range(5):
    print("\n")
  for i in range(10):
    sys.stdout.write("\b"*32)



def exit():
  def terminal(line):
    
    line=line.split()
    
    if line!=[]:
      instruction=line[0]+"("
      cmd=line[0]
      del line[0]
      
      if line!=[]:
        instruction+="'"+"','".join(line)+"')"
      else:
        instruction+=")"
    
    try:
      return eval(instruction)
    except NameError:
      print("bash:",cmd,"\b: command not found")
    #except:
    print("bash: error")
  
  while True:
    wd=str("/"+"/".join(fswd))
    wd=wd[0:5].replace("/root","~")+wd[6:len(wd)]
    line=input(str(user)+"-"+wd+chr(36)+" ")
    retour=terminal(line)
    if retour=="python":
      break

print("\nWelcome on Linux terminal \nemulator :\n")
exit()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.