Skip to content

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. …

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…

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 withou…

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. …

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 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