File Path Format to Access Network Drives

I can access a network drive successfully using the Script Console and the following formats, but not from a Gateway Event / Project script.

I got my network drive path using the Command Prompt command: > net use
I got the IP Address of the server by using: > ping SERVERNAME


Script Console
Input

import os
print 'Server Name References:'
print os.path.isdir('\\\SERVER\\FOLDER\\folder')
print os.path.isdir('\\\SERVER/FOLDER/folder')
print os.path.isdir(r'\\SERVER\FOLDER\folder')
print os.path.isdir(r'\\SERVER/FOLDER/folder')
print os.path.isdir('\\\\SERVER\\FOLDER\\folder')
print os.path.isdir('\\\\SERVER/FOLDER/folder')
print 'IP Adrress References:'
print os.path.isdir(r'\\\IPADDRESS\\FOLDER\\folder')
print os.path.isdir(r'\\\IPADDRESS\\FOLDER\\folder')
print os.path.isdir(r'\\\IPADDRESS/FOLDER/folder')
print os.path.isdir(r'\\IPADDRESS\FOLDER\folder')
print os.path.isdir(r'\\IPADDRESS/FOLDER/folder')
print os.path.isdir('\\\\IPADDRESS\\FOLDER\\folder')
print os.path.isdir('\\\\IPADDRESS/FOLDER/folder')

Output

Jython 2.5.3 (v2.5.3:3d2dbae23c52+, Nov 17 2012, 11:51:23) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_171

>>> 
Server Name References:
True
True
True
True
True
True
IP Adrress References:
True
True
True
True
True
True
True


Gateway Startup Event Script

project.watcher

Project Script watcher

import os
GWLog = system.util.getLogger("GatewayStartupEventLog")
GWLog.info('Server Name References:')
GWLog.info(str(os.path.isdir('\\\SERVER\\FOLDER\\folder')))
GWLog.info(str(os.path.isdir('\\\SERVER/FOLDER/folder')))
GWLog.info(str(os.path.isdir(r'\\SERVER\FOLDER\folder')))
GWLog.info(str(os.path.isdir(r'\\SERVER/FOLDER/folder')))
GWLog.info(str(os.path.isdir('\\\\SERVER\\FOLDER\\folder')))
GWLog.info(str(os.path.isdir('\\\\SERVER/FOLDER/folder')))
GWLog.info('IP Adrress References:')
GWLog.info(str(os.path.isdir(r'\\\IPADDRESS\\FOLDER\\folder')))
GWLog.info(str(os.path.isdir(r'\\\IPADDRESS\\FOLDER\\folder')))
GWLog.info(str(os.path.isdir(r'\\\IPADDRESS/FOLDER/folder')))
GWLog.info(str(os.path.isdir(r'\\IPADDRESS\FOLDER\folder')))
GWLog.info(str(os.path.isdir(r'\\IPADDRESS/FOLDER/folder')))
GWLog.info(str(os.path.isdir('\\\\IPADDRESS\\FOLDER\\folder')))
GWLog.info(str(os.path.isdir('\\\\IPADDRESS/FOLDER/folder')))

Gateway Logs

GatewayStartupEventLog	25May2018 10:39:23	False
GatewayStartupEventLog	25May2018 10:39:23	False
GatewayStartupEventLog	25May2018 10:39:23	False
GatewayStartupEventLog	25May2018 10:39:22	False
GatewayStartupEventLog	25May2018 10:39:22	False
GatewayStartupEventLog	25May2018 10:39:22	False
GatewayStartupEventLog	25May2018 10:39:22	False
GatewayStartupEventLog	25May2018 10:39:21	IP Adrress References:
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:21	False
GatewayStartupEventLog	25May2018 10:39:20	Server Name References:

I took a look at the guide for mapping network drives but I don’t have the permissions for editing config files on my laptop. I am designing in a local test environment.

You need to follow the guide in order for gateway-scoped scripts to be able to access network drives.

When you run the script in the playground (designer scope), the Designer process belongs to your user and the drives are accessed as your user.

When you run it in the gateway scope, the process is the Ignition Gateway, running as a service under the service account, and the permissions will be different.

2 Likes