Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Send cmd commands from my python script

cmd python

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1 Bissy

Bissy

    CC Regular

  • Member
  • PipPipPip
  • 47 posts

Posted 16 April 2013 - 12:27 PM

Question is in the title really, the various guides i have searched for are seriously unclear and i need someone who has experience and knows how to help me. I've been searching for 2 days on this topic and still haven't found an answer. If you need anymore info in order to help  me just reply and i'll provide it

 

Cheers guys



#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 16 April 2013 - 10:43 PM

There's many ways, everyone with advantages and disadvantages on its own, read this article that summarizes them



#3 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts

Posted 17 April 2013 - 04:51 AM

On Linux I do it like this:
 
import subprocess

return_code = subprocess.call([name,arg1,arg2])
I don't see why it wouldn't work on Windoze too.

Edited by Yannbane, 17 April 2013 - 04:51 AM.

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#4 Bissy

Bissy

    CC Regular

  • Member
  • PipPipPip
  • 47 posts

Posted 17 April 2013 - 08:30 AM

so if i wanted to run this piece of code: youtube-dl (http://www.youtube.c...h?v=6E2hYDIFDIU) to the command line from my python script, how would i go about it? Because it does run when done on my command prompt

 

without the brackets


Edited by Bissy, 17 April 2013 - 08:33 AM.


#5 Flying Dutchman

Flying Dutchman

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1090 posts

Posted 17 April 2013 - 07:43 PM

youtube-dl -o filename.flv http://url.com/video

Probably meant how to pass arguments, not call from script.


The roots of education are bitter, but the fruit is sweet.


#6 Bissy

Bissy

    CC Regular

  • Member
  • PipPipPip
  • 47 posts

Posted 18 April 2013 - 09:00 AM

I did, but when i tried the command it didn't work:/. I could seriously do with a simple clear and precise tutorial on how the subprocess module work i'd really appreciate it



#7 Flying Dutchman

Flying Dutchman

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1090 posts

Posted 18 April 2013 - 09:20 AM

What errors do you get?

 

Also, Yannbane pretty much showed how to use subprocess.


The roots of education are bitter, but the fruit is sweet.


#8 Bissy

Bissy

    CC Regular

  • Member
  • PipPipPip
  • 47 posts

Posted 18 April 2013 - 09:27 AM

Am not even sure if am running the arguments right, and the command prompts comes for like a quick second then quits, and am just downloading how do i see the output






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download