Questions tagged [python-cmd]

cmd is a module in the Python Standard Library for writing line-oriented command interpreters.

46 questions
1
vote
0 answers

Terminal Color Breaking the Prompt - Cmd Module

I am using cmd module and colorama module, when I use colorama module to add color to the prompt it's just breaking the prompt. If I run the script without color then it's working fine Sample Image I tried google, there are some solution for bash…
Jeeva Kumar
  • 353
  • 2
  • 8
1
vote
1 answer

Is it possible to use Python's cmd module remotely with multiple TCP clients?

I created a python script that I'm running on my server which provides a simple command line interface for running custom configuration scripts. I'm using the cmd module to do this and it's been working great so far: from cmd import Cmd class…
1
vote
1 answer

Python application with both interactive and inline mode

I am trying to create a Python command-line app, which supports both interactive (currently using Cmd) and inline modes (like Python's python -c). Is there a good way to do it without duplicating the 'line parsing' code?
Elad Weiss
  • 3,662
  • 3
  • 22
  • 50
1
vote
1 answer

Twisted and a command line interface

I have a program where I want to do two things: Interact with a server and respond to events from the server. I am doing this using twisted. Have a command line prompt for the user where he can issue additional commands. I am using the python cmd…
Leonidaz0r
  • 180
  • 10
1
vote
1 answer

python cmd module exit shortcut

Using python cmd module, I would like to be able to quit the command line application using Ctrl+D. However, default behavior prints ^D instead of quitting the application. Reading the documentation, I can't seem to find a way to do it. Any hints ?
Overdrivr
  • 6,296
  • 5
  • 44
  • 70
1
vote
1 answer

python interactive shell using cmd repeating statements with no arguments typed

New to python and i'm working on an interactive shell using cmd that takes defined functions and arguments and returns value in an if/then format. Example below. But my issue is that every time the user types a function and i return something to the…
1
vote
1 answer

cmd.Cmd object doesn't return any value

I am currently creating a command-based game using Python's cmd module. At a certain point, my cmd.Cmd objects get nested. If I say that I am running the command prompt A, at a certain point a new prompt B is created inside A. I want to, when my B…
RGS
  • 964
  • 2
  • 10
  • 27
0
votes
0 answers

Tab auto completion of commands is not working when sys.stdout is overwritten with custom Logger class object in a python program with cmd module

I want to store the commands and their output to be stored in log.txt . So, i am assigning customer Logger class object to sys.stdout with write method overriden to store the output both in file as well as to print in console. The problem here is…
Sekhar
  • 1
  • 2
0
votes
2 answers

How to make a list of commands and then display it in a table

so I've decided to try to make a nice cmd menu on windows in python, but I got stuck on one of the first things. I want to create a list of commands and then display them in a table.I am using prettytable to create the tables. So I would like my…
yakubiq
  • 27
  • 4
0
votes
0 answers

How to add interactive shell to socketserver in python

I want to use the cmd Python library, which provides an interactive shell to the tcp server, but it does not work properly. The application will have more than one infinite loop one for the server called serve_forever and one for the shell called…
loaded_dypper
  • 262
  • 3
  • 12
0
votes
1 answer

How to implement clear in cmd.Cmd?

I am working on a custom command line interpreter, and I want to implement the 'clear' command, just like the the one in bash shell. Is there any way to do that? I have attempted it but I don't think it is correct at all: #!/usr/bin/python3 import…
Leuel Asfaw
  • 316
  • 1
  • 14
0
votes
0 answers

Issue with members adding in telegram group through python

I am trying to add members to a telegram group using python-cmd through GitHub (Telegram adder & scrapper script). I am done with all processes correctly, at last members were not added to the group. Can someone guide me through this…
0
votes
1 answer

Different behavior with different lists in a complete_xxx function in a cmd shell

I am using the cmd module to create a simple shell. For two commands, I have two different lists. For one, the completion works as expected, but the other it doesn't. [Good list] IntList="eth0", "eth1", "eth2" [Bad List]…
0
votes
1 answer

Python Cmd: trying to return a value from a function but told it is being referenced before assignment

im making a game with pythons cmd module but I've run into this problem. I have a function that I pass a variable into, the function changes it and returns it. but when I set the function equal to the variable it says that value has been referenced…
James.L
  • 55
  • 5
0
votes
0 answers

Modify Python cmd module's history on Windows

My Python program has an interactive command line implemented with cmd module. How can I add commands to cmd history (so that it can be reached by cursor-up shortcut)? Please, note the program runs on Windows so readline library tricks aren't…
jackhab
  • 17,128
  • 37
  • 99
  • 136