Tuesday, March 7, 2017

Any ideas on why os.system() could fail?

Though i added all the programs I needed to Path, I never took a look at the ComSpec environment variable.
Apparently, I added C:\Program Files (x86)\Java\jre7\bin to comspec in addition to the default %SystemRoot%\system32\cmd.exe.
The solution was to either add all the paths from Path to ComSpec as well, or simply remove the path to the Java binary.


WHAT ABOUT A CODE FOR A TROJAN ?...
I want to remove everything before the wa path.
p = path.split('/')
counter = 0
while True:
if p[counter] == 'wa':
break
counter += 1
path = '/'+'/'.join(p[counter:])
For instance, I want '/book/html/wa/foo/bar/' to become '/wa/foo/bar/'
would be to use os.path.relpath:
>>> import os
>>> full_path = '/book/html/wa/foo/bar/'
>>> print os.path.relpath(full_path, '/book/html')
'wa/foo/bar'
http://stackoverflow.com/questions/8693024/how-to-remove-a-path-prefix-in-python



No comments: