# Global name 'system' is not defined

**URL:** <https://forum.inductiveautomation.com/t/global-name-system-is-not-defined/15612>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [October 9, 2017, 4:33pm UTC](https://forum.inductiveautomation.com/t/global-name-system-is-not-defined/15612 "2017-10-09T16:33:08Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![flavien](https://avatars.discourse-cdn.com/v4/letter/f/f475e1/32.png) [@flavien](https://forum.inductiveautomation.com/u/flavien)\
**Post date:** [October 8, 2019, 2:59pm UTC](https://forum.inductiveautomation.com/t/global-name-system-is-not-defined/15612/7 "2019-10-08T14:59:40Z")

</div>

I have the same error with the gateway event script - Tag Change below :

```auto
import StringIO
import csv
import os
import ftplib
import sys
import system
from datetime import date
from datetime import datetime
from datetime import timedelta

if newValue.value==0:
	sys.exit()

today=date.today() #Récupère la date du jour au format 'aaaa-mm-jj'
datejour= str(today).replace('-','') #Remplace les - par rien
yesterday=date.today() - timedelta(days=1) #Récupère la date de la veille
yesterday_jour=str(yesterday).replace('-','') #Remplace les - par rien
#print datejour,yesterday_jour

ftp = ftplib.FTP('myip') 
ftp.login('user','password')
files = [] #créé liste vide
ftp.retrlines('NLST', files.append) #Récupère la liste des fichiers dans le dossier du FTP et alimente la liste

#print files

def callback(buf):
	ftmp=system.file.getTempFile("data")
	#print ftmp
	
	f=open(ftmp, 'wb')
	f.write(buf)
	system.file.writeFile("C:\\TempTest\\NewTest.data",buf)
	#print buf
	
	dataIn=	StringIO.StringIO(buf)
	reader=csv.reader(dataIn, delimiter=';', quotechar="\"")
	dataOut=[]
	headers=["Poste","Nom","Date","DJU"]
	for row in reader:
		dataOut.append(row)
	#print dataOut
	
	date=datetime.strptime(dataOut[-1][2]+'000000','%Y%m%d%H%M%S')
	dju=dataOut[-1][3].replace(',','.')
	#print dataOut[-1][2], dju,date
	
	
	f.close()
	
	query="INSERT INTO dju (t_stamp,dju) VALUES (?,?)"
	system.db.runPrepUpdate(query,[date,dju])

filename="DJU_"+yesterday_jour+".data"
#print filename
ftp.retrbinary('RETR '+filename, callback)
ftp.voidcmd('QUIT')
ftp.close()

```

Thanks

---

_[View the full topic](https://forum.inductiveautomation.com/t/global-name-system-is-not-defined/15612)._
