Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Sys Process Execute Command

jbunel
2018-04-13
2023-11-17
  • jbunel - 2018-04-13

    Hello evrybody.
    there is many post about the SysProcess library and particulary about the "Execute Command".

    I 've follow some exemple read in this forum and it works fine on my Raspberry pi, but only the command which doesn't need to be execute in the graphic interface.

    I explain :
    First i adjust the CODESYSControl.cfg to

    [SysProcess]
    Command=AllowAll
    

    If i try to excute :

    command1 := 'reboot';
    "SysProcess SysProcess Execute Command2(pszCommand:=command1 ...)
    

    it works fine

    and if i try to excute :

    command1 := 'leafpad';
    Β "SysProcess SysProcess Execute Command2(pszCommand:=command1 ...)
    

    nothing append

    if run the command 'leafpad' in the rasbperry command terminal, it works.

    So is it possible to execute command or program with graphic interface.

    Thank you.

     
  • eschwellinger

    eschwellinger - 2018-04-13

    Hi,
    if this is >=3.5SP11 there is the section for doing this in /etc/CODESYSControl_User.cfg

    so move your setting/section from /etc/CODESYSControl.cfg to /etc/CODESYSControl_User.cfg

    BR
    Edwin

     
  • jbunel - 2018-04-16

    Hi Edwin.
    I use the last one so : 3.5.12.20

    I tried to move the setting

    [SysProcess]
    Command=AllowAll
    

    from /etc/CODESYSControl.cfg to /etc/CODESYSControl_User.cfg.
    but same result.

    it seems that the runtime process does not have the rights to execute graphical applicaton

     
  • Frank Wenzel - 2020-01-27

    Do we have a solution for that until now?

     
  • ferrim - 2020-04-01

    Same problem here...

     
  • eschwellinger

    eschwellinger - 2020-04-02

    which plc and which version?

     
  • eschwellinger

    eschwellinger - 2020-04-02

    Hi,
    we had a similar problem to execute VLC player, for us the solution was:
    sudo -u pi DISPLAY=:0 vlc /home/pi/Videos/CODESYS.mp4

     
  • ferrim - 2020-04-02

    Thank you very much, your advice works fine!

     
  • ilyart - 2021-04-09

    Hi! Having hard times with SysProcessExecuteCommand.
    Running on Raspberry, runtime 4.0.1.0

    CODESYSControl_User.cfg

    [SysProcess]
    Command=AllowAll
    Command.0=shutdown
    ;Command.1=sudo
    

    Executing any command returns zero. If add double quotes it returns 25 as a result and doing noting.

     
  • fabian - 2023-11-17

    Hello,

    I have a question:
    Once the command is being executed, is there a way to kill it again?
    As the called application is running in the background, the user can't close it but it shall be closed/terminated, commanded by codesys.

    I have tried with "SysProcessTerminate" but I guess this is not correct as the RTE crashes when this function is called.

    Starting the application:

    IF GVL.xStrtQR THEN
        GVL.xStrtQR := FALSE;
        SysProcess.SysProcessExecuteCommand2(pszCommand:=sCmd, pszStdOut:=stdout, udiStdOutLen:= SIZEOF(stdout),pResult := ADR(GVL.pResQRTsk));
    END_IF
    

    Trying to stop it again:

    IF GVL.xTrmQR THEN
        GVL.xTrmQR := FALSE;
    
        pResTerm := SysProcess.SysProcessTerminate(hProcess:=SysProcess.SysProcessGetCurrentHandle(pResult:=ADR(GVL.pResQRTsk)));
    END_IF
    

    Codesyscontrol Win x64, 3.5.19.10.

    Many thanks for any advice pointing to the correct direction.. :-)

    Regards,
    Fabian

     

Log in to post a comment.