<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/</id><updated>2025-09-12T23:04:47.136000Z</updated><subtitle>Recent posts to SysProcess Execute Command unable to run commands with special characters</subtitle><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#0547" rel="alternate"/><published>2025-09-12T23:04:47.136000Z</published><updated>2025-09-12T23:04:47.136000Z</updated><author><name>kurtk</name><uri>https://forge.codesys.com/u/kurtk/</uri></author><id>https://forge.codesys.com2a51bfe3b1dd13b0f6476ab5265ed1064db7044c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for this additional information.&lt;br/&gt;
Could you please provide the references to the official documentation&lt;br/&gt;
 where you found this information ?&lt;/p&gt;
&lt;p&gt;I got as far as:&lt;/p&gt;
&lt;p&gt;Then insert this:&lt;br/&gt;
&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;br/&gt;
BasePriority=Realtime&lt;br/&gt;
Command=AllowAll&lt;/p&gt;
&lt;p&gt;devoid of references of where the CodesysContol.cfg file&lt;br/&gt;
was located or of the need to run codesys as root&lt;br/&gt;
I incrementally located bits of information with perplexity searches but remained mired at error 25 ERR_NO_ACCESS&lt;/p&gt;
&lt;p&gt;I am curious whether root access is MANDATORY to run&lt;br/&gt;
SysProcessExecuteCommand (- and/or any other SysProcess functions)&lt;br/&gt;
or if a more access-constrained&lt;br/&gt;
User=quasiroot&lt;br/&gt;
could suffice without the security concerns ?&lt;/p&gt;
&lt;p&gt;Apparently codesys runs fine without User=root for almost everything...&lt;br/&gt;
That raises the question: What IS the default codesys user ?&lt;/p&gt;
&lt;p&gt;I notice in the prototypes:&lt;br/&gt;
VAR&lt;br/&gt;
sCommand : STRING := '/usr/bin/whoami';&lt;br/&gt;
sOutput : STRING(255);&lt;br/&gt;
refCommand : REFERENCE TO STRING;&lt;br/&gt;
refOutput : REFERENCE TO STRING;&lt;br/&gt;
resultCmd : UDINT;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;whenever  I attempt to build this Codesys v3.5 SP2 whines that&lt;br/&gt;
"cannot convert type REFERENCE TO STRING to STRING"&lt;br/&gt;
don't remember the exact message...&lt;br/&gt;
Apparently this happens whenever a fixed-length string is&lt;br/&gt;
involved. if I get rid of (255) and just &lt;br/&gt;
set the string  := '                       '; that is sufficient to make the compiler happy.&lt;br/&gt;
Is this a recently enforced constraint ?&lt;br/&gt;
Why does this compile for you and not for me ?&lt;/p&gt;
&lt;p&gt;There are references to functions / utilities which are used/needed to massage the string references - but I see no specific details...&lt;/p&gt;
&lt;p&gt;I also notice you specify:&lt;br/&gt;
Make sure the lib SysProcessImplementation, SysTypes, and CmpErrors is on the project.&lt;/p&gt;
&lt;p&gt;I don't comprehend why all of the dependent libraries are not automatically referenced, added ?&lt;br/&gt;
I don't recall seeing anywhere but here that SysProcessImplementation must be included...&lt;br/&gt;
It just seems odd that the default is to exclude essential libraries, or require alchemical conjuring to assemble all the ingredients for gnat soup ;-)&lt;/p&gt;
&lt;p&gt;Thanks a lot... I'm still a codesys newby getting my wheels on - or sometimes just partially on&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#f4d2" rel="alternate"/><published>2025-05-20T13:09:03.298000Z</published><updated>2025-05-20T13:09:03.298000Z</updated><author><name>edson-bueno</name><uri>https://forge.codesys.com/u/edson-bueno/</uri></author><id>https://forge.codesys.com6f026ecb593abd36f08be22dc4c613f5e4bd617b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I found the same issue, and I fixed with this steps:&lt;br/&gt;
1st go to codesys .cfg file.&lt;/p&gt;
&lt;p&gt;sudo nano CODESYSControl.cfg &lt;/p&gt;
&lt;p&gt;Then insert this:&lt;br/&gt;
&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;br/&gt;
BasePriority=Realtime&lt;br/&gt;
Command=AllowAll &lt;/p&gt;
&lt;p&gt;Now we need to grant codesys root rights on Linux.&lt;/p&gt;
&lt;p&gt;Step 1:&lt;br/&gt;
Create or edit the systemd override configuration:&lt;br/&gt;
sudo systemctl edit codesyscontrol&lt;/p&gt;
&lt;p&gt;In the editor that opens, insert:&lt;br/&gt;
&lt;span&gt;[Service]&lt;/span&gt;&lt;br/&gt;
User=root&lt;/p&gt;
&lt;p&gt;Save and exit:&lt;/p&gt;
&lt;p&gt;Press Ctrl+O to save&lt;/p&gt;
&lt;p&gt;Press Ctrl+X to exit&lt;/p&gt;
&lt;p&gt;Step 2: Reload systemd and reboot&lt;br/&gt;
To apply the override:&lt;br/&gt;
sudo systemctl daemon-reexec&lt;br/&gt;
sudo systemctl daemon-reload&lt;br/&gt;
sudo reboot&lt;/p&gt;
&lt;p&gt;Step 3: Confirm CODESYS is running as root&lt;br/&gt;
After reboot, open the terminal and run:&lt;br/&gt;
ps aux | grep codesyscontrol&lt;/p&gt;
&lt;p&gt;You should see something like:&lt;br/&gt;
root      1234  ... /opt/codesys/bin/codesyscontrol.bin ...&lt;/p&gt;
&lt;p&gt;If instead it shows admin or another user, the override was not applied correctly.&lt;/p&gt;
&lt;p&gt;Step 4: (Optional) Confirm from within CODESYS&lt;br/&gt;
In your CODESYS project, insert this test code to run the Linux command whoami:&lt;/p&gt;
&lt;p&gt;Make sure the lib SysProcessImplementation, SysTypes, and CmpErrors is on the project.&lt;/p&gt;
&lt;p&gt;VAR&lt;br/&gt;
    sCommand   : STRING := '/usr/bin/whoami';&lt;br/&gt;
    sOutput    : STRING(255);&lt;br/&gt;
    refCommand : REFERENCE TO STRING;&lt;br/&gt;
    refOutput  : REFERENCE TO STRING;&lt;br/&gt;
    resultCmd  : UDINT;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;refCommand REF= sCommand;&lt;br/&gt;
refOutput  REF= sOutput;&lt;/p&gt;
&lt;p&gt;SysProcessExecuteCommand2(&lt;br/&gt;
    pszCommand := refCommand,&lt;br/&gt;
    pszStdOut := refOutput,&lt;br/&gt;
    udiStdOutLen := SIZEOF(sOutput),&lt;br/&gt;
    pResult := ADR(resultCmd)&lt;br/&gt;
);&lt;/p&gt;
&lt;p&gt;Notes &amp;amp; Warnings&lt;br/&gt;
This method gives full system access to the CODESYS runtime — do not expose this system to the public network without protection.&lt;/p&gt;
&lt;p&gt;Do not use sudo in commands inside CODESYS when the runtime is already running as root.&lt;/p&gt;
&lt;p&gt;&lt;a class="user-mention" href="/u/tomas111/profile/"&gt;@tomas111&lt;/a&gt;, in case you want to read the temperatur, use this command:&lt;br/&gt;
sCommand:STRING:='/usr/bin/vcgencmd measure_temp';&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#30cb" rel="alternate"/><published>2023-04-22T13:35:37.671000Z</published><updated>2023-04-22T13:35:37.671000Z</updated><author><name>tomas111</name><uri>https://forge.codesys.com/u/tomas111/</uri></author><id>https://forge.codesys.comadde654d0535ab160aa51f048c0cb935191bc30c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;tried on version CS 18 SP4 with targeter 4.7.0.0?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#da2e" rel="alternate"/><published>2022-12-03T13:24:06.696000Z</published><updated>2022-12-03T13:24:06.696000Z</updated><author><name>tomas111</name><uri>https://forge.codesys.com/u/tomas111/</uri></author><id>https://forge.codesys.comcf3df6895dc6df80fc81d78412bbc4bc1ca38248</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have a general problem with temperature. Raspberry 4. I did everything as in the settings but does not show. Maybe I'm editing the file in the wrong way?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#664e" rel="alternate"/><published>2022-12-02T17:03:15.635000Z</published><updated>2022-12-02T17:03:15.635000Z</updated><author><name>jackm</name><uri>https://forge.codesys.com/u/jackm/</uri></author><id>https://forge.codesys.com03fa5aa1174fe8b07981c8eae9f26e11c8e9a13d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;No, I have not figured out a way to resolve this issue yet.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#26d9" rel="alternate"/><published>2022-12-02T09:28:34.335000Z</published><updated>2022-12-02T09:28:34.335000Z</updated><author><name>tomas111</name><uri>https://forge.codesys.com/u/tomas111/</uri></author><id>https://forge.codesys.com7e8cdddd216a5b581e2c43d49f0d81210cbd316a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Did you manage to solve the issue?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SysProcess Execute Command unable to run commands with special characters</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/1ddc279005/?limit=25#dda0" rel="alternate"/><published>2022-12-01T07:14:39.593000Z</published><updated>2022-12-01T07:14:39.593000Z</updated><author><name>jackm</name><uri>https://forge.codesys.com/u/jackm/</uri></author><id>https://forge.codesys.combac3485783c067761c4a00ad4f5c5f8d635d3774</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am using SysProcessExecuteCommand to run linux commands through Codesys, and have no issues when Command=AllowAll. However, when I try to limit the commands allowed to execute, any commands with a special charater (ex. "*", ";", or "|") no longer works. I receive a pResult of 25 (INT), which from my research means "No access rights for this operation".&lt;/p&gt;
&lt;p&gt;Just as an example, the command 'find /HMI_Deploy/*.v' would execute fine with Command=AllowAll, but will not execute when given a Command.0=find instead. The find command will still execute in both situations if the * is removed. &lt;/p&gt;
&lt;p&gt;Below are what I have written in the CODESYSCONTROL.cfg file:&lt;br/&gt;
&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;br/&gt;
Command.0=cd&lt;br/&gt;
Command.1=ls&lt;br/&gt;
Command.2=find&lt;br/&gt;
Command.3=iptables&lt;br/&gt;
Command.4=echo&lt;br/&gt;
Command.5=touch&lt;br/&gt;
Command.6=printf&lt;br/&gt;
Command.7=ftp&lt;br/&gt;
Command.8=|&lt;br/&gt;
Command.9=;&lt;br/&gt;
Command.10=*&lt;em&gt;&lt;br/&gt;
Command.11=\&lt;/em&gt;*&lt;br/&gt;
Command.12=\;&lt;br/&gt;
Command.13=\|&lt;/p&gt;
&lt;p&gt;I am currently using Codesys V3.5 SP16 Patch 4 and running version 3.6.16.0 of the SysProcess Implementation Library.&lt;/p&gt;
&lt;p&gt;Can I get help on how to allow the use of special characters in my commands?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>