system() call not executing a command

조회 수: 2 (최근 30일)
Tim
Tim 2013년 7월 3일
I'm trying to run an external program within a MATLAB class. The command doesn't seem to execute in the shell (ubuntu 12.04, MATLAB 2012b).
commandstring = sprintf('avl %s %s < %s &', avlfilepath, runfilepath, commandfilepath);
result = system(commandstring);
The issue isn't with the commandstring, upon inspection it looks okay:
avl /tmp/URDF.avl /tmp/URDF.run < /tmp/myavlcommands.txt &
When I copy and paste this into the terminal, it executes perfectly. If I examine the output with the second output argument out of system, it is an empty string. Running the command in the terminal produces a host of text that comes through stdout.
Other commands like system('echo hi') and system('gedit test.txt') execute fine though.
I've also tried taking the ampersand off the end of the command, but then the text file doesn't get properly piped in to the executable when it is run through system().
I'm out of ideas. Anyone have any ideas or seen any similar problems?
  댓글 수: 1
Tim
Tim 2013년 7월 3일
편집: Tim 2013년 7월 3일
Seems to be a workaround--the program was written in FORTRAN. This workaround works (well enough for me), but if anyone has a more elegant answer/explanation, I'd still appreciate it.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by