python - Run CMD line from within SPSS -
is there way run windows command line within spss?
i'm working program not supported spss begin program procedures , run command line spss syntax (i'm not interested in output , don't need import/export spss data want run cmd line within spss).
to take simpler example using freeware, let's want run r script @ end of spss syntax work version not supported spss (e.g. @ moment spss 21 supports r 2.14, let's absolutely need run on r 2.15 installed on windows pc), there way run
r cmd batch c:\files\myrcode.r
within spss syntax?
this equivalent running program (in case r) in batch mode. program need use not r, it's example.
as far i'm aware spss can't maybe using python (through spss begin program python) 1 can run command line using python?
thanks
p.s. python users may not have used spss before 1 should in theory able run python code within spss using
begin program python. run python code end program.
yes, can python code:
begin program python. import subprocess subprocess.call(['c:\\r\\r.exe', 'cmd', 'batch', 'c:\\files\\myrcode.r']) end program.
or, directly, this:
host command=['r cmd batch c:\files\myrcode.r'].
alternatives:
- put in batch file execute it, example using
os.system()
. - execute python or basic script through
script
command.
Comments
Post a Comment