command

Windows command prompt in Python

Windows command prompt in Python Question: I have the following code which captures traffic packets, write them into a traffic.pcap file, then convert the pcap to text file using the tshark. If I enter the full path and name of the files in the last line, the code works perfectly, however it is always overwriting …

Total answers: 1

How to get all fish shell commands from a python script?

How to get all fish shell commands from a python script? Question: When I run complete -C from my regular terminal fish shell I get a list of ~4k commands, which is great. I want this to happen from my python script. I have the following but it doesn’t work: command = "fish -c ‘complete …

Total answers: 3

Powershell Filepath command is being altered by Pycharm

Powershell Filepath command is being altered by Pycharm Question: I’m trying to run a file path powershell command through python. ` import subprocess subprocess.call(‘powershell.exe cd OneDriveDesktopOpenPoseopenpose-1.7.0-binaries-win64-gpu-python3.7-flir-3d_recommended’, shell=True) ` The error message displays: Cannot find path ‘C:UserscubeowOneDriveDesktopOpenPoseImplementationOneDriveDesktopOpenPoseopenpose-1.7.0-binarie s-win64-gpu-python3.7-flir-3d_recommended’ because it does not exist. The error message showed that they had added a root path in front …

Total answers: 1

How to run batch file (.bat) or command silently from python?

How to run batch file (.bat) or command silently from python? Question: How do I run a batch file from python without it echoing? print("doing command") with open("batch.bat", "w") as f: f.write("@echo offnsome_command") subprocess.call([‘batch.bat’]) input("finished command") Expected result: doing command finished command Result: doing command Some command results finished command I tried using os.system instead …

Total answers: 1

Calling multiple functions which have multiple variables with one button. Self argument doesn't get recognized

Calling multiple functions which have multiple variables with one button. Self argument doesn't get recognized Question: I have to execute several functions with one button click. The functions have multiple variables. I think I’m pretty close to get it working but when I click the button the error TypeError: all_functions.function_1() missing 1 required positional argument: …

Total answers: 2

Python script for 'ps aux' command

Python script for 'ps aux' command Question: I have tried to use subprocess.check_output() for getting the ps aux command using python but it looks like not working with the large grep string. Can anyone have any solution? subprocess.check_output(‘ps aux | grep "bin/scrapy" | grep "option1" | grep "option2" | grep "option3" | grep "option4" | …

Total answers: 2

subprocess.run only accepting first argument

subprocess.run only accepting first argument Question: Using Python 3.10.6 trying to pass an argument to a command line opened via subprocess.run, I’ve tried toggling shell=True/False, as well as passing the second argument with the input variable, no luck. here is the relevant code: cmds = ([‘cmd’,’echo hello’]) cmd_result = subprocess.run(cmds, shell=False, check=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, …

Total answers: 1

Break down this @client.command() snippet

Break down this @client.command() snippet Question: I am trying to modify the following code but I’ve come to the conclusion I don’t fully understand what is taking place here. If someone would be so kind as to break it down for me line by line I’d be appreciative. @client.command(name=’cmd’) async def cmd(context): command = context.message.content.replace("!cmd …

Total answers: 1

Discord Bot Not Responding to Commands (Python)

Discord Bot Not Responding to Commands (Python) Question: I’ve just gotten into writing discord bots. While trying to follow online instructions and tutorials, my bot would not respond to commands. It responded perfectly fine to on_message(), but no matter what I try it won’t respond to commands. I’m sure it’s something simple, but I would …

Total answers: 3