Jump to content
OMRON Forums

Script 'system' call not jiving with documentation


Recommended Posts

I've been investigating using the script System call to invoke some background C programs and do some work, however I'm running into behavior contrary to the documentation.


The manual includes this example:

system"/opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0";

However, when executed, I get an error that

sh: /opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0: No such file or directory


This isn't super surprising; sh is being passed the entire string and is interpreting it as the executable to find, rather than as an executable followed by arguments. If I just move the quote:

system"/opt/ppmac/tune/parabolicmove" 1 2000 500 0 0 0;

this works fine - the executable is invoked with the right arguments.


Now, the crux is the other feature advertised in the manual, the ability to pass a formatted string with arguments to system. Ideally, I'd do something like

system"/opt/ppmac/app/doWork %d %d %d",pVariable1,pVariable2,pVariable3


This doesn't work for two reasons:

system "/var/ftp/usrflash/foo.out %d %d %d",10,20,30
sh: /var/ftp/usrflash/foo.out %d %d %d,10,20,30: No such file or directory


The file not being found is expected per the initial issue. However, given that, what I'd _expect_ to not be found is

"/var/ftp/usrflash/foo.out 10 20 30"

rather than the full pattern.


How can I format a command to the system from script? Am I doing something wrong? Is the manual wrong?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The manual is correct. I believe the response “sh: /opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0: No such file or directory” is a result of using the raw “system” command in the terminal window not as a program command in a plc or prog. When used as an on-line command in the terminal you would not use the quotes as in:

system /opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0


The on-line usage only supports a literal string as the argument . The “formatted text string” is supported as a buffered command in plc or prog only.


You can however use the “buffered” version with “formatted text string” support in the terminal window with the cx command as in the following:

cx system "/opt/ppmac/tune/parabolicmove %u %u %u %u %u %u",1,2000,500,0,0,0


I was successfully able to execute the following in a plc:


open plc parabolic

Ldata.SystemCmdStatus = 999

system "/opt/ppmac/tune/parabolicmove %u %u %u %u %u %u",1,2000,500,0,0,0

while (Ldata.SystemCmdStatus > 0) {}

p99 = Ldata.SystemCmdStatus

disable plc parabolic


Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...