python - Using a stat with a variable -


i writing script checks octal permissions of files , folders in linux. struggling line of code:

stat -c %a check 

check raw input user, example /home. when run script in terminal following error message when line above executed:

file "check.py", line 17 stat -c %a check                ^ syntaxerror: invalid syntax 

i tried putting check in brackets , got:

traceback (most recent call last):   file "check.py", line 34, in <module> main()   file "check.py", line 31, in main     folderexists(check)   file "check.py", line 17, in folderexists     stat -c %a (check) nameerror: global name 'c' not defined 

that line should executed in terminal, not in python script. contains invalid python syntax.

if want issue system command python, can use os.system:

import os os.system('stat -c %a check') 

if need add values command string, use str.format:

import os os.system('stat -c {} check'.format(value)) 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -