hello ive been working on a small project and im a bit stuck.

import subprocess

path = "/var/log"

#i wanna be able to do something like 
subprocess.call("nano path")
# but i noticed that using nano like that wont work because path is just a python string
any help

thanks im gonna test it out as soon as i get home and give an update

unfortunately i did not get our solution to work i kept getting an error "file or directory not found" however after a little digging Here i realized that to get subprocess() to execute "nano path" i would have to supply arguments as alist eg.

import subprocess

path = "somefile.txt"

subprocess.call([nano, path])

The other solution is to add shell = True to subprocess.call()'s arguments.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.