I am running Jupyter notebook on a server (python 3).

Want to see output of OS command (any OS command - this is just example):

output = os.system("pwd")

When I do print of it:

print (output)

Response is 0.

How to get a simple output (like in CLI)?

Thanks.

2 Answers

1
Fabrizio On
import os

print(os.getcwd())
print(os.system("pwd"))

But this question is a duplicate: how to show current directory in ipython promp

1
Joe On

Just found it on internet and wanted to post.

It needs to be:

print(os.popen('ls').read())

(or any other OS command).

This works fine.