# Scheduled Gateway Event Script writing to shared drive succeeds but doesnt actually write anything

**URL:** <https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [February 2, 2024, 3:20pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161 "2024-02-02T15:20:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [February 2, 2024, 3:20pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/1 "2024-02-02T15:20:56Z")

</div>

I have a gateway scheduled script with the following script:

```auto
def onScheduledEvent():    
    tbl = system.db.runNamedQuery('Project_Name', 'select_LastWeek_Data')
	
	csv = system.dataset.toCSV(tbl)
	
	startDater = system.date.addDays(system.date.now(), -7)
	
	startDate = system.date.format(startDater, 'YYYYMMddHHmmss')
	endDate = system.date.format(system.date.now(), 'YYYYMMddHHmmss')
	
	filePath = "\\enterprise.domainName.net\shares\someFolder\someOtherFolder\Reports\TestFile2.csv"

	system.file.writeFile(filePath, csv)
```

And I can see the SUCCESS message in the gateway scripts.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/40a53a689d4d0bcd361f599793d0321ffe51ae77.png)

However, my file never appears in the given file path.

Any thoughts on what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 2, 2024, 3:39pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/2 "2024-02-02T15:39:02Z")

</div>

> [@bmeyers](#):
>
> `filePath = "\\enterprise.domainName.net\shares\someFolder\someOtherFolder\Reports\TestFile2.csv"`

Not sure if this is the issue, but I'd expect this path is missing all the backslashes it needs:

```auto
filePath = "\\\\enterprise.domainName.net\\shares\\someFolder\\someOtherFolder\\Reports\\TestFile2.csv"

```

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [February 2, 2024, 3:41pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/3 "2024-02-02T15:41:33Z")

</div>

Error message this time:

```auto
Traceback (most recent call last):
  File "<Export__History_to_Excel>", line 15, in onScheduledEvent
IOError: [Errno 2] File not found - \\enterprise.domainName.net\shares\BEL\someFolder\someOtherFolder\Reports\TestFile2.csv (Access is denied)

8.1.32 (b2023091211)
Azul Systems, Inc. 11.0.18
```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 2, 2024, 3:42pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/4 "2024-02-02T15:42:22Z")

</div>

Well now you have a real problem to track down.

Maybe you need to map the network drive? [Mapping a Network Drive - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Mapping+a+Network+Drive)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [February 2, 2024, 3:51pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/5 "2024-02-02T15:51:54Z")

</div>

We did do that... we added the following to the bottom of the config file and stopped / started the gateway.

```auto
wrapper.share.1.location=\\serverName.global.domainName.net\public
wrapper.share.1.target=W:
wrapper.share.1.type=DISK
wrapper.share.1.account=ts\myUserName
wrapper.share.1.password= ********
```

I then update my gateway script to the following:

```auto
filePath = "W://Reports//TestFile2.csv"
system.file.writeFile(filePath, csv)
```

I can navigate to the path [\serverName.global.domainName.net\public\Reports] so I know it exists. I get this error when running the updated gateway script:

```auto
Traceback (most recent call last):
  File "<Export_History_to_Excel>", line 16, in onScheduledEvent
IOError: [Errno 2] File not found - W:\Reports\TestFile2.csv (Access is denied)

8.1.32 (b2023091211)
Azul Systems, Inc. 11.0.18
```

My assumption is I setup the config file wrong but I don't know how to prove it. Any thoughts? The lines of code I added are on the bottom of the config file.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 2, 2024, 4:02pm UTC](https://forum.inductiveautomation.com/t/scheduled-gateway-event-script-writing-to-shared-drive-succeeds-but-doesnt-actually-write-anything/85161/6 "2024-02-02T16:02:46Z")

</div>

It looks right, it just seems like a permissions problem at this point... maybe somebody else or support has dealt with a similar situation.
