2

I want to concatenate several bash commands in a python file. Doing that for one command works:

import os
os.system('ls -l')

However if I dont know how to concatenate with another command like pwd

0

2 Answers 2

4

Use && and so:

import os
os.system('ls -l && pwd')

This will execute pwd on the successful execution of "ls -l"

Sign up to request clarification or add additional context in comments.

Comments

1

Use a semicolon if you want to always execute command 2, regardless of whether or not command 1 ran successfully:

import os
os.system('ls -l; pwd')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.