Syntax problem with command in cmd

14 vues (au cours des 30 derniers jours)
Pantelis
Pantelis le 21 Avr 2025
Hello, I am currently in the process of running something in cmd via matlab. I want to run the porgramm compose for a certain file.
The below line runs perfectly in cmd without any problem.
"C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml"
[Inserted commands in edit mode for clearer reading, editing...dpb]
"C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml"
When i run this from matlab system("C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml") it doesnt work, giving these errors Syntax error at line number 1 near character position 1
Error: 'filePath' is not defined at line number 17 in file get_stress.oml
system("C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml")
Syntax error at line number 1 near character position 1
Error: 'filePath' is not defined at line number 17 in file get_stress.oml
I think its a Syntax error in this and its about these ".
After I fix this problem I want to be able to define this middle part ("filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" ) with something like sprintf so it changes dynamically.
"filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d"

Réponses (1)

Walter Roberson
Walter Roberson le 21 Avr 2025
system("C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml")
% ^ ^
You start and end a string literal, and then you have -e which would try to subtract a variable named e
You need
system('"C:\Program Files\Altair\2025\Compose2025\Compose_Console.bat" -e "filePath=C:/Users/pantm/OneDrive/Desktop/TEST_LCA_doublelane_0.h3d" -f "C:/Users/pantm/OneDrive/Desktop/get_stress.oml"')

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Tags

Produits


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by