I'd like to load cmd.exe and call a bat file with multiple parameters. All these from python.
My bat file looks like:
@echo off
call ifortvars.bat intel64
cd %5
abaqus job=#1 user=%2 cpus=%3 gpus=%4 interactive
My python code:
os.system("start cmd.exe /k C:/Users/username/desktop/file.bat" params)
where:
params = [JobName, fname, str(numcpus), '1', 'C:/Abaqus_Jobs' + JobDir]
JobName = 'A2'
JobDir = 'Job1/input_files'
fnameUEL = 'routineUEL'
numcpus = 8
Now this code does not work because params
is a list. If I change it to:
os.system("start cmd.exe /k C:/Users/username/desktop/file.bat JobName fname str(numcpus) '1' 'C:/Abaqus_Jobs' + JobDir)
it also does not work. I've read that cmd in windows works:
Spaces in Program Path + parameters with spaces:
CMD /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
but if I try:
os.system("start cmd.exe /k ""C:/Users/username/desktop/file.bat" "JobName" "fname" "str(numcpus)" "1" "'C:/Abaqus_Jobs' + JobDir"")
it doesn't work either. Any ideas? Thanks!