Syntax problem with command in cmd

조회 수: 10 (최근 30일)
Pantelis
Pantelis 2025년 4월 21일
답변: Walter Roberson 2025년 4월 21일
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