except FileNotFoundError: pass os.write(2, (rightHS[0] + ":command not found \n").encode()) sys.exit(1) while (1): # added the < 3 because PS1 was still printing an extrneous string if 'PS1' in os.environ and len( os.environ['PS1']) < 3: # Requirement 1 Prompt String. os.write(1, (os.environ['PS1']).encode()) else: os.write(1, "$ ".encode()) input = my_getLine() # Get input from method created in Lab Assignment #0 args = input.split() if len(input) == 0: # If input is empty break if input.lower() == "exit": # Requirement 4: exit command os.write(2, ("Shell Exited \n".encode())) sys.exit(1) if args[0] == "cd": #Requirement 4: cd command if len(args) == 1: os.chdir("..") else: os.chdir(args[1]) continue # Return to top of while
continue break if s is None: print('could not open socket') sys.exit(1) delay = float(paramMap['delay']) if delay != 0: print(f"sleeping for {delays}s") time.sleep(delay) print("Done sleeping") fs = frameSock(s) input = my_getLine() command, localfile, host, remotefile = parseTCPInput(input) print(localfile) print(remotefile) fs.messagesend(remotefile.encode()) #sending file responsesvr = fs.messagercv() #receive servers response print(responsesvr) if responsesvr == "No": os.write(2, ("File cannot be transferred").encode()) elif responsesvr == 'Ok': #If file is "Ok" filedir = os.open(localfile, os.O_RDONLY) message = os.read(filedir, 100)
if s is None: print("could not open socket") sys.exit(1) delay = float(paramMap['delay']) if delay != 0: print(f"sleeping for {delays}s") time.sleep(delay) print("done sleeping") #above code provided by Dr.Freudenthal# fs = framedSocket() #create instance of framedSocket class input = my_getLine() #input from the user command,localfile,host,remotefile = parseTCPInput(input) #parse input and get filename fs.sendMessage(remotefile.encode()) reply = fs.receiveMessage() if reply =="NO": OS.WRITE(2,("Failed").encode()) sys.exit(1) else: fd = os.open(localfile, os.O_RDONLY) buff = "" message = ""