Execute and Distribute to Remote Computer

Hi there,

I feel like I'm quite close on this, but I'm hoping someone could give me some insight into saving a PDF report to another computer on the network.

This is the code I've been using to save a report locally:

pathString = "C:\MES\Reports\" # The location on the MES Server where we save reports
fileName = "Line Report.pdf" # Full file name
settings = {"path":pathString, "fileName":fileName, "format":"pdf"} # Settings parameters for the function
reportPath = "Template/" + equipment # The location of the template we're using
projectName = system.util.getProjectName() # Gets the project name of the current project
parameterList = {"StartDate":startDate, "EndDate":endDate, "LineNumber":lineNumber, "ShiftName":shiftName, "ProfileName":profileName} # Specify report parameters
actionType = "save"

system.report.executeAndDistribute(path=reportPath, project=projectName, parameters=parameterList, action=actionType, actionSettings=settings)

I'm trying to write code to save this same report to another computer on the network, but I haven't gotten it to work yet.

As far as I know, assuming the folder on the remote computer is shared with read/write access (which this folder is) I should just be able to change my path string to point at this other folder. For my case, the remote computer is at 192.168.65.125, so I modified the code to:

pathString = "\192.168.65.125\MES\Reports\" # The location on the MES Server where we save reports
fileName = "Line Report.pdf" # Full file name
settings = {"path":pathString, "fileName":fileName, "format":"pdf"} # Settings parameters for the function
reportPath = "Template/" + equipment # The location of the template we're using
projectName = system.util.getProjectName() # Gets the project name of the current project
parameterList = {"StartDate":startDate, "EndDate":endDate, "LineNumber":lineNumber, "ShiftName":shiftName, "ProfileName":profileName} # Specify report parameters
actionType = "save"

system.report.executeAndDistribute(path=reportPath, project=projectName, parameters=parameterList, action=actionType, actionSettings=settings)

I've tried changing the path to include the host name instead, removing slashes, adding slashes. Nothing I've done has worked so far. Does anyone know if there is any other parameter I need to change or if I should be using a different instruction to save remotely? Perhaps there is a windows setting I'm missing that is hindering me?

Thanks in advance.

Two things are likely involved:

  1. Ignition runs as the “Local System” account on the gateway machine, by default. As a service. This account has no privileges of its own for network access. See this part of the manual for mapping external drive letters for the service.

  2. Python strings process backslashes as escapes for special characters. You have to double them up in script string constants. Or just use forward slashes instead. I don’t recall encountering any filesystem operation in python that won’t work with forward slashes.

2 Likes

Also looks like you're missing the double quotes at the start, before the ip address:
\\\\192.168.65.125\\MES\\Reports

1 Like

Thanks for your quick responses @pturmel and @nminchin. I should’ve noticed when the text above turned my double slashes into single ones - the IP address needed 4 back slashes in front of it.
Also, to your 2nd point, just using forward slashes worked fine as well.

Thanks guys!