File Write to a Network Location

I am trying to write a file to a network location from a gateway script. I am sure it is a permissions issue, but I’m not exactly sure how the gateway scripts differ from any other command.

I have a script in the Script Modules that writes a file. If I call the script from a button press when running the application on the gateway server, it works. If I call the script from a gateway timer, it gives a couple of possible errors.

If I attempt to write to a mapped network drive (Y:) it gives the error:
Traceback (most recent call last):
File “<TimerScript:IFI_12430_CNCUnloadCell/tmrMain @750ms >”, line 15, in
File “module:Test”, line 153, in WriteTestFile
IOError: The system cannot find the path specified

If I attempt to write directly to the network location(\\IP\folder), it gives the error:
Traceback (most recent call last):
File “<TimerScript:IFI_12430_CNCUnloadCell/tmrMain @750ms >”, line 15, in
File “module:Test”, line 153, in WriteTestFile
IOError: Logon failure: unknown user name or bad password

This might help you out. The Ignition software uses a program called Java Service Wrapper to run the JVM from an native executable. There are some properties that you can add to data/ignition.conf that magically mounts a network drive so that you can use it in gateway scripts. A configuration example is at the bottom of the page here.

1 Like

Thanks, I will give that a shot. Is there a particular location in the .conf file that I need to add the logic to? Do I need to restart the gateway before the change will take affect?

I don’t think it matters where you put the text in the file. But yes, you do have to restart the gateway. Also, to be absolutely sure that the wrapper program reloads the .conf file, stop the gateway and then start it as separate commands rather than just restarting in 1 command.

I added the following the ignition.conf file and I saw no change. I still get the same errors.

wrapper.share.1.location=\172.18.1.30\UserFiles
wrapper.share.1.target=Y:
wrapper.share.1.account=username
wrapper.share.1.password=password
wrapper.share.1.startup.premapped=CONTINUE
wrapper.share.1.startup.max_retries=5
wrapper.share.1.startup.retry_interval=10

I can get the file to write from a client script as well. I can make it work by creating a stand-alone application that runs on the server, to write from a client script, but it is not ideal. What authentication would the gateway use that is different from the client?
I should note that the remote pc and the server have different login id’s and the remote pc is in the same network, but does not log on to a domain.
I am writing a file from the gateway to another computer on the same network with no issues. I just can’t seem to find what is different about this computer vs the one that I can write to.

The big difference between Client and Gateway scope is that a logged in user is running the Client scripts and some pre-determined user is running the Gateway scoped scripts. The latter should run through the user that the Ignition service was installed under (which is usually just ‘Local System Account’). You can change it to log on as a different user in the Windows Services program (services.msc). If your new username has permissions to access that shared folder, then it should work!

I had a similar application and just got it working, it was kind of a permissions issue. To make it work on a Windows 7 system, you need to run Ignition as a service, and tell it to log on not as the current user but as your local admin account. That got me the permissions I needed to make the java wrapper code work. I added in one other line to it for troubleshooting till I got it working and that was wrapper.share.1.failure=SHUTDOWN. It wouldn’t let the Ignition service start until I got the login thing figured out. I just commented it out when I wasn’t working on that part so it would run normally.

I cannot find the ignition.conf file anywhere, has this changed? Thanks

No, this file location did not change. The ignition.conf file can be found in the installation directory of Ignition. Should look like

              \Program Files\Inductive Automation\Ignition\data\ignition.conf

this would be for Windows installations

I am revisiting this, I am attempting to setup a mapped network drive and have been unsuccessful. I have the log file enabled but I am not getting any errors in the wrapper.log, but its not working either.

When i try to access a file path from a gateway script I get:
OSError: (2, ‘No such file or directory’, ‘V:\Network’)

Setup:
windows server 2008 R2
Ignition 7.6.4
Mapped a windows network drive to the PC already and works fine.

Can anyone give me some suggestions to try, I’m logged in as an admin.

Thanks,
Drew

How you mapped the network drive?

With the iginiton.conf file or with the GUI of windows?

I think that if you do it with the second way, the mapped network only lives in the security context of your current user logged in (in this case, admin).

The Ignition Gateway Service runs as Local Service (if you not change that) and don’t see the drives mapped by admin context (I think)

Regards,

initially I set up the mapped drive with windows only, when my scripts failed to reach the mapped drive i found this post on the forum and set up the parameters in the ignition.conf file.

I also followed instructions at:
inductiveautomation.com/sup … /ignition/

Nothing shows up in the wrapper.log that says its failing or trying to connect. I am going to call support and see if they can help out

I am still unable to get it fully working but I’m Close. here is my current setup but i am still getting an error. The names and locations have been changed to protect the Innocent.

CONFIG:
wrapper.share.1.location=\1.2.3.4\Network
wrapper.share.1.target=V:
wrapper.share.1.type=Disk
wrapper.ntservice.account=me
wrapper.ntservice.account=me1
wrapper.share.1.account=here\me
wrapper.share.1.password=me1
wrapper.share.1.startup.premapped=CONTINUE
wrapper.share.1.startup.max_retries=5
wrapper.share.1.startup.retry_interval=10

ERROR:
Unable to map “V:”. Trying to continue. (The network path was not found. (0x35))

SO, now i have the drive mapped successfully but i cannot access the drive letter. Any suggestions? thx

Any errors?

I had a similar issue. I was trying to write pdf bytes to a folder on our network using system.file.write().

The solution was to obviously make sure you have raw strings, and to use built-in python functions.

ReportBytes = …
iFile = open( r’\MyServer\Folder\iPDF.pdf’, ‘wb’ )
iFile.write( ReportBytes )
iFile.close()