-4

I'm trying to call a cmd command using the python script. but it has no effect.

import os
os.system('--youtube-dl')
Anthon
  • 59,987
  • 25
  • 170
  • 228

2 Answers2

1

You can use the subprocess module to do all that kind of stuff I've included a small example below

from subprocess import call
call(['youtube-dl', 'https://www.youtube.com/watch?v=PT2_F-1esPk'])

Python docs to subprocess

sudo
  • 886
  • 2
  • 14
  • 31
  • `ls` is (at least on Unix/Linux) systems also available as a binary, you are not invoking the `ls` from your shell (an certainly not `cmd`) – Anthon Apr 23 '17 at 06:03
  • @Anthon yes i just gave a simple example of call and nothing was coming to my mind – sudo Apr 23 '17 at 06:09
0

You are calling the exectuable --youtube-dl which probably not exists.

If --youtube-dl is a command you can type in from the cmd prompt, you should try subprocess.check_output(['--youtube-dl', some_url], shell=True) then the cmd.exe (at least on Windows) will get invoked.

Anthon
  • 59,987
  • 25
  • 170
  • 228