0

I would like to convert this Matlab code to Python syntax. The aim of this code is to executing a shell command via Matlab to run an abaqus simulation with a specific target.

string = ['C:\Windows\System32\cmd.exe /E:ON /V:ON /K' ...

'""C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.8.254\windows\bin\ipsxe-comp-vars.bat" intel64 vs2013 & abaqus ' ...

'j=v1 '...

'inp=v1.inp '...

'user=vumat_randomFields_v3.for '...

'int & exit"'];

job1 = system(string);

I tried to use subprocess module ,but I did not succeed .

import subprocess
string = [r'C:\Windows\System32\cmd.exe','/E:ON','/V:ON','/K',
          r'"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.8.254\windows\bin\ipsxe-comp-vars.bat" intel64 vs2013 & abaqus',
          'j=v2',
          'inp=v1.inp',
          'user=vumat_randomFields_v3.for',
          'int', 'exit']

command='abaqus job=v1 user=vumat_randomFields_v3 verbose=2 int'

job1 = subprocess.call(command, shell=True)

I did not get any python error; however, the job did not run. Via matlab the job normally ran.

To mention I am using Windows and python 3.10

I would appreciate any help. Best Regards

0x01010
  • 168
  • 12
  • As far as I can tell, this question is a duplicate of [this one](https://stackoverflow.com/q/89228/7328782). Please [edit] your post to clarify how this is not a duplicate by showing what you did and telling us why that didn’t work. – Cris Luengo Jun 25 '23 at 15:29
  • I did. Thank you – Rafeek Serhal Jun 25 '23 at 15:54
  • In your Python code, you define `string` with the same command you use in MATLAB, and then you don’t use that variable. Instead you run an `abaqus` command. – Cris Luengo Jun 25 '23 at 15:59
  • 1
    My bad, I solved the problem. The code should be like below import subprocess command = r'C:\Windows\System32\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.8.254\windows\bin\ipsxe-comp-vars.bat" intel64 vs2013 & abaqus j=v1 inp=v1.inp user=vumat_randomFields_v3.for int & exit"' subprocess.run(command, shell=True) – Rafeek Serhal Jun 25 '23 at 16:32

0 Answers0