Syntax problem with command in cmd

6 次查看(过去 30 天)
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"

回答(1 个)

Walter Roberson
Walter Roberson 2025-4-21
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"')

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by