Skip to content
Advertisement

Tag: shell

How to invoke a specific shell with python?

I want to invoke a specific command shell in python to execute some scripts. For exemple, in R, I use: system2(os_shell = “C:/Program Files (x86)/pgAdmin III/1.18/pg_dump.exe”, args = “very long argument”) Thanks to this code, I can backup my Postgresql’s tables with a for loop. Problem: I didn’t find an equivalent in Python. Answer If you just want to execute

Change “conda activate” command in terminal? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question Can I change the command conda activate env_name to activate the environment? Instead, I want to give my custom command. Is that possible? Answer You

Make python3 as my default python on Mac for Fish shell

Every time I type python into the console it uses Python 2.7. I would like it to use the latest version (I have it installed), Python 3.9. How do I do this using the fish shell (other StackOverFlow talks about for bash)? Answer First, look where it is installed : note the line which ends with python3.9 without anything (as

Run python command inside a bash script and get the result

I would like to run a python command that return true or false inside a bash script: The code above is just to sketch the idea. I need boolean to be false or true (bash boolean values) depending on the result of …operations…. The code above is not working: boolean results to be an empty variable. Answer bool=$(python -c ‘print(bool(“abc”))’)

python: subprocess returns nothing when running scripts which take longer time

Beginner here with subrpocess problem: The below line works fine when I run both the scripts with less data which takes around 10-20minutes, however with bigger data to be processed the subprocess returns nothing once both the scripts are completed (lets say in an hour). Also: Often with lesser data, it behaves abnormally as well i.e. not returning the status_code/going

Detect whether current shell is powershell in python

What’s the recommended way to check which shell is my python program running inside? I know I can query os.environ.get(‘SHELL’) for the shell name, but what can I use to determine powershell? Answer Generally, environment variable SHELL does not tell you what shell invoked your script, it only tells you the binary path of the current user’s default shell (on

Python code for finding top 5 processes using cpu

I am new to python and I have a simple problem of finding the top processes using the CPU. I was able to do it in shell using ps and sort. I have checked few but links but it do not help partly because the function is defined as below, ps_input will be something like below, Can someone help me

Advertisement