Send a run file command from PAC script


#1

I am looking for a way to send a command from a PAC strategy to a Linux os (possibly a SendCommunicationCommand) that will run a program file.

For example, if I have a python file dir/function.py, could I execute that file from TCP/FTP? stemming from a PAC script?


#2

Ooooo, great question.
Really looking forward to see what the hive mind can come up with on this oneā€¦

Off the top of my head, I have three ideas.

  1. Node-RED. If you are running it, then it would be dead simple to have a PAC Node to listen for a variable and an Exec Node to call the function.py.
    Just hooking those two nodes together should just about do it, but you might need a RBE or Function Node between them to sort out the msg.payload.

  2. FTP. The PAC Controller has a sweet set of FTP commands and so does every Linux distro known to planet Earth.
    So, the PAC Controller shoots a dummy.txt file to the FTP server on the Linux PC.
    The Linux PC has a cron job that every second (or five) looks for dummy.txt and when it sees it, deletes it and calls function.py.

  3. The hard way.
    Run Apache and have it listen for an incoming connection from the PAC Controller and then have some PHP call the function.py.
    A very rough outline about this method can be found here; Plot a graph from MySQL data


#3

@Beno We tried Option 1 and it seems to be working great! We included our example.


Node Red scans for a PAC variable and when we turn that variable on, it triggers the execute node via the switch node.