cmd is a module in the Python Standard Library for writing line-oriented command interpreters.
Questions tagged [python-cmd]
46 questions
0
votes
1 answer
How to check if completion is available in a python cmd.Cmd program
Standard cmd module provide nice tools to build a CLI with auto completion by default if readline support is available.
However I wonder how can I know from inside the program whether this support is effectively available or not and though whether…

WIP
- 348
- 2
- 11
0
votes
1 answer
Python3 Print statement using .format() prints in reverse
I am trying to create a simple terminal-based game in Python 3. I'm using cmd module to make a menu, and within it I use a test script. Here's the code.
from assets import *
from cmd import Cmd
from test import TestFunction
import base64
class…

The Gaming Hideout
- 574
- 2
- 10
- 26
0
votes
0 answers
Pythonunit test: output after execution of the test should be displayed in the log
Used packages:
Paramiko and Unittest
Details
A somewhat special question that is probably quite easy to answer.
I am currently testing the functionality on a cmd level with a unit test. In this test case, a cmd command is listed on a switch on the…

Mornon
- 59
- 5
- 22
0
votes
0 answers
Python cmd module enter key
I've built a simple cli app using cmd. I noticed that hitting the enter key seems to be rerunning the previous command. Is there a way to catch/prevent this?

frodo
- 1,561
- 3
- 21
- 36
0
votes
1 answer
Different result in cmd and IDLE python
I have a Python 2.7 script that works perfectly only on IDLE, the result looking like this :
**Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more…
0
votes
0 answers
Split a string containing json w/spaces into arguments
I am implementing a command shell using cmd2, and I wanted to setup a few commands that allows a user to type in objects in json syntax. I thought this would be easy to do with argparse, but I am getting caught up how to parse and present the string…

ytjohn
- 197
- 1
- 7
0
votes
0 answers
Python socket server send remote commands
Right now, I'm trying to make a socket server in Python that takes input from a client, processes it, does whatever is need to be done, and then sends a message back to the client showing that it's done.
The problem I am having right now is that…

Brian Shen
- 21
- 8
0
votes
0 answers
Python 3 cmd.Cmd append space after do_function(): completion
I'm using the cmd.Cmd library for a command line tool that I'm building and am mildly annoyed that using tab to auto-complete a command, the command line is left at the end of the command instead of appending a space to easily facilitate adding…

Amperand
- 3
- 2
0
votes
0 answers
Constantly log into console using python3 cmd module
I'm trying to make something like server using python's CMD module for interaction, but I cannot find any information about printing logs into console on-the-fly without command "printLogs"
The good example of interaction with server is steamCMD.
Is…

Igor Lihachev
- 25
- 4
0
votes
1 answer
Instantiate nested Cmd Interpreter in Python
Hi I'm looking to create a nested interpreter in Python using the Cmd module.
I set up a dynamic module loading because I want my project to be easily expandable (i.e. add a new python file into a folder and without changing the main code being able…

ptr0x01
- 627
- 2
- 10
- 25
0
votes
1 answer
Keeping track of current input before user presses enter
I'm using Python's cmd module to handle a terminal input loop.
I have a thread running in the background, which prints out some stuff in the terminal when it receives a message. These messages break the visual user input:
> writing a com
@@@ message…

Juicy
- 11,840
- 35
- 123
- 212
0
votes
3 answers
python cmd module context based completion
In python cmd module, when I press the TAB button, I get the list of possible commands that are available and that I have defined in my cmd.Cmd class.
My question is whether it is possible to show a set of commands based on the context like in a…

badtrains
- 91
- 1
- 2
- 9
0
votes
0 answers
Python 2.7 to exe using py2exe issue
I successfully created an .exe using py2exe with a simple test script I found on a tutorials website. The script I am using, however, does not seem to work. My code uses the csv module and dict reader with two .csv inputs.
I run the python…

Paden
- 1
-1
votes
1 answer
How to run commands in a external file through command prompt using python?
My Requirement is -
I have set of commands written in a "commands.ftp" file, to upload a "request.txt" file to FTP server.
I want to call the command prompt from my python file and run the commands in the "commands.ftp" file one by one .
Once all…

Gyanaranjan Nayak
- 49
- 8
-2
votes
2 answers
Python Cmd: How to edit the last command
I am working on a small command line application based on the Cmd Python module. I can't see how to show the last command in the console prompt so that it can be edited by the user and re-submitted.
The question is not about how to store the last…

Andrea Sindico
- 7,358
- 6
- 47
- 84