Code: gist.github.com/nikhilkumarsingh/c23fbd592b4268f225cb895afaa187fe 2:32 Old methods of running shell commands (os.system, os.popen, os.spawn) 7:25 Introduction to subprocess module 11:05 Run command and read output 15:43 Run command by passing single string (shell parameter) 16:40 Security considerations while using shell paramter 22:58 Run command and pass input 26:50 Run command with timeout 27:56 Run command and throw error if fail
how do I edit files(files like cat/etc/hosts or etc/selinux/config (the things that we can edit using vim or nano on terminal)) by using python(like i run the .py file in terminal and that file gets edited instead of me manually editing it) pls help if someone has any clue, or pls give me videos/ links related to this if anyone knows. need help
Wow that was so helpful!! I didn’t realize how straightforward it could be with the subprocess module. I was so overwhelmed I tried to just write a bash script instead to run shell commands but that ended up taking forever because my bash skills aren’t that good yet. Thanks and Keep up the great work!
My doubt is suppose I have a bat/shell script file that accepts multiple user inputs... So how can we execute this bat file from the python script and even handle/automate the user inputs from python script itself?
Hey Bro what if the shell command I am executing does need another input in the middle of processing. Like it needs to press Y/N to confirm the execution. How can i do this.
Hi, I am getting error in using this subprocess to open the hostapd file in terminal of rasbian software. I am getting the error " Too many errors from stdin "
Say I am in file abc.py and need to open command prompt from abc.py and pass new path and new command to newly opened command prompt, how do I do this?
Hi this video was so interesting. I have stuck in one of the issue while using this run with minicom. problem : running this command ["minicom", "-D", "/dev/ttyUSB1"] after this i will turn on device that will start booting for 30 secs and it will ask for inputs. how to do that? is running commands once minicom triggered is it possible?
perfect vid! at the very end of the vid, you showed how to check if there is an error. I'm wondering how to not only check for error but also what specifically the error is about. How would you recommend doing it?
#p = subprocess.run(["python3", "universal.py"],shell=True,capture_output=True,input='SP600-6') #p = subprocess.run(["python3", "universal.py"],capture_output=True,input="SP600-6".encode(), text=True) p = subprocess.run(["python3", "universal.py"],capture_output=True, stdin=open("a.txt",'r')) None of the above work? What am I doing wrong on windows machine?
how do I edit files(files like cat/etc/hosts or etc/selinux/config (the things that we can edit using vim or nano on terminal)) by using python(like i run the .py file in terminal and that file gets edited instead of me manually editing it) pls help if someone has any clue, or pls give me videos/ links related to this if anyone knows. need help
Code: gist.github.com/nikhilkumarsingh/c23fbd592b4268f225cb895afaa187fe
2:32 Old methods of running shell commands (os.system, os.popen, os.spawn)
7:25 Introduction to subprocess module
11:05 Run command and read output
15:43 Run command by passing single string (shell parameter)
16:40 Security considerations while using shell paramter
22:58 Run command and pass input
26:50 Run command with timeout
27:56 Run command and throw error if fail
how do I edit files(files like cat/etc/hosts or etc/selinux/config (the things that we can edit using vim or nano on terminal)) by using python(like i run the .py file in terminal and that file gets edited instead of me manually editing it) pls help if someone has any clue, or pls give me videos/ links related to this if anyone knows. need help
How can i run command = (New-Object -com "WMPlayer.OCX.7").cdromcollection.item(0) in powershell using python.
Please help..
Wow that was so helpful!! I didn’t realize how straightforward it could be with the subprocess module.
I was so overwhelmed I tried to just write a bash script instead to run shell commands but that ended up taking forever because my bash skills aren’t that good yet.
Thanks and Keep up the great work!
You are an amazing person. Thats what I was looking for. Thank you Sir!
is there any way to run multiple shell commands in the same process instance? like reusing Popen?
keep making these video mate !! content is superb
Nice video! Quick note, shell is '/bin/sh', not '/usr/sh' :-)
You helped me so much with my scripts
My doubt is suppose I have a bat/shell script file that accepts multiple user inputs... So how can we execute this bat file from the python script and even handle/automate the user inputs from python script itself?
Hey Bro what if the shell command I am executing does need another input in the middle of processing. Like it needs to press Y/N to confirm the execution.
How can i do this.
Hi Nikhil, your tutorials are very informative. Thanks for uploading!
Very, very, Very good!
Thank you Very much!
Hi, I am getting error in using this subprocess to open the hostapd file in terminal of rasbian software. I am getting the error " Too many errors from stdin "
Is there any way to get live output like rclone copy progress???
I have echo $1 in my shell script...I am trying to pass Hello as parameter/ input from python script.Any idea
Bro faceing issue
subprocess' has no attribute 'run
how to fix it
Thanks a lot !! Mate !! Learned so much from you
How to awk command in python , I tried using it with subprocess but getting below error .
awk is not recognised as an internal or external command .
Say I am in file abc.py and need to open command prompt from abc.py and pass new path and new command to newly opened command prompt, how do I do this?
HI sir i want to get version of powershell by using python script. can you help me?
os kya hei bro? And what is the theme ?
This was an easy and amazing video . Thank you for putting it here
gret lesson , super tnx you 😀
Great overview on the subject..
Thanks for this video love you brother
Very useful, Thanks
Very nice! Thanks
Nice useful video - thanks for making this available
Awesome Explanation
Is there any way to run commands in to and fro manner from python code to command line?
Hi how run command as administrator in python script
Hi this video was so interesting. I have stuck in one of the issue while using this run with minicom.
problem : running this command ["minicom", "-D", "/dev/ttyUSB1"] after this i will turn on device that will start booting for 30 secs and it will ask for inputs. how to do that?
is running commands once minicom triggered is it possible?
Great Bro ❤️
How to run an program which has a infinite while loop or application such as iperf server and client way to kill the process
Amazing!! thank you alot!
Thanks for the video friend... can you do more of these which are used in Production, like for Linux Admin tasks
what distro are you using/ desktop enviroment
I use Fedora Linux.. What about You bro ?
Linux mint bro
perfect vid! at the very end of the vid, you showed how to check if there is an error. I'm wondering how to not only check for error but also what specifically the error is about. How would you recommend doing it?
I 've just subbed pls do more videos like this
can you make the video for reading the dictionary by key to get value using shell command in python
Hi sir, need help for python coding. Where can I contact you?
#p = subprocess.run(["python3", "universal.py"],shell=True,capture_output=True,input='SP600-6')
#p = subprocess.run(["python3", "universal.py"],capture_output=True,input="SP600-6".encode(), text=True)
p = subprocess.run(["python3", "universal.py"],capture_output=True, stdin=open("a.txt",'r'))
None of the above work? What am I doing wrong on windows machine?
Thank you so much, i what i was looking for
Can u make a tutorial of making a simple gui application, which runs cmd commands
Thank you!
how do I edit files(files like cat/etc/hosts or etc/selinux/config (the things that we can edit using vim or nano on terminal)) by using python(like i run the .py file in terminal and that file gets edited instead of me manually editing it) pls help if someone has any clue, or pls give me videos/ links related to this if anyone knows. need help
sed
Great vid, Thanks alot
How to run command as administrator with python script
Could you do a version in English?
Thank you 🙏
Nice
congratulations I found you
👍