user11388175
user11388175

Reputation:

How to pass multiple command in os.popen

Anyone can help me that how to pass two commands in Popen function

I have to pass following two command to be executed in cmd console

  1. netsh wlan set hostednetwork mode=allow ssid=kumawat_infinity key=123456789a
  2. NETSH WLAN start hostednetwork

These command will enable hotspot in window.

import os

os.popen('netsh wlan set hostednetwork mode=allow ssid=kumawat_infinity  key=123456789a')

os.popen('NETSH WLAN start hostednetwork')

Upvotes: 0

Views: 80

Answers (1)

Green Cloak Guy
Green Cloak Guy

Reputation: 24711

You can just put both your commands in the same string, separated by a semicolon. This is the function of the semicolon in the bash programming language.

Example:

os.popen(
    'netsh wlan set hostednetwork mode=allow ssid=kumawat_infinity  key=123456789a; netsh wlan start hostednetwork'
)

Upvotes: 1

Related Questions