I can list the root directory using a script file and command line.
%%writefile ShowDir.py
import os
import sys
from sys import argv
DIR = argv[1]
show = os.listdir(DIR)
print show
Then I ran in the terminal:
!echo mypassword | sudo -S python ShowDir.py /root
It worked, but I want a more graceful approach.
I also tried:
This will run files, make directories, remove files directories, but for some reason will not LIST them.
import os, subprocess
ret = subprocess.check_call("echo mypassword | sudo -S ls /root", shell=True)
ret
It just returned a 0, no directory listing