how to close connection after running cuteFTP .vbs script? - file-upload

we are using the macro record facility available in cuteFTP to generate a vbs file which we use to upload a local copy of the database to Godaddy.
How do we go about closing the connection on upload completion as if we do not there is a risk that the file is locked and causes the website to fall over? Is there a better way to do this?
thanks for any pointers
' Create TEConnection object
Set MySite = CreateObject("CuteFTPPro.TEConnection")
' Initialize remote server host name, protocol, port, etc.
MySite.Host = "ftp.servername.here"
MySite.Protocol = "FTP"
MySite.Port = 21
MySite.Retries = 30
MySite.Delay = 30
MySite.MaxConnections = 4
MySite.TransferType = "AUTO"
MySite.DataChannel = "DEFAULT"
MySite.AutoRename = "OFF"
' WARNING!!! SENSITIVE DATA: user name and password.
MySite.Login = "username"
MySite.Password = "password"
MySite.SocksInfo = ""
MySite.ProxyInfo = ""
' Connect to remote server
MySite.Connect
MySite.UploadAsync "C:\Projects\access_db\propertyDB.mdb", "/access_db/propertyDB.mdb"

A quick look at the Official Documentation suggests you could use the Close() method and pass the "EXITNOPENDING" option as an argument.
From the Official Documentation:
Close
Use the Close method to exit the Transfer Engine. You can include parameters to exit only on certain conditions.
Syntax
Object.Close (BSTR bstrParameter)
Parameters
""(default empty), "CLOSE", "EXIT"—Closes TE (all tasks will be stopped)
"EXITNOPENDING"—Closes TE if no pending tasks available
Example
Set MySite = CreateObject("CuteFTPPro.TEConnection")
MySite.LocalFolder = "c:\temp"
MySite.TransferURLAsync "ftp://ftp.cuteftp.com/pub/cuteftp"
MySite.Close "EXITNOPENDING"

Related

PYODBC not closing connection to Access Database

I'm trying to load data from an Access databse using PYODBC.
The code I wrote is this:
#Connection Parameters
MDB = 'C:/Users/xxxx/Documents/EugeneVideo.mdb'
DRV = '{Microsoft Access Driver (*.mdb, *.accdb)}'
PWD = 'PW'
pyodbc.pooling = False
con = pyodbc.connect('DRIVER={};DBQ={};PWD={}'.format(DRV,MDB,PWD))
SQL = """SELECT * FROM Customers WHERE c_state = 'CA' """
df = pd.read_sql_query(SQL, con)
csr = con.cursor()
csr.close()
con.close()
At the first time, it runs nicely.
The data is stored in a dataframe.
But if I try to run the script again, changing, for instance the filter parameter, python crashes.
I noticed that the LDB file is not being deleted after the first run, so, apparently, the connection is not being closed even I explicitly ask for that.
Where are the error? Is there a better way to assure that the connection will be closed?
I've already have tried the class methods, with similar results.
Cheers
I solved this issue by enabling VB in File -> Options -> Trust Center.

How to open a Lotus Notes Database on a network share?

I am trying to interact with a Notes database (my personal mail file), via C# and am stuck right out of the gate, trying to open the database with the following code:
string sNotesSourceFolder = "$Inbox";
string sUserName = "scady";
string sMailFile = #"NotesMail_FDrive\ARchives\" + sUserName + ".nsf";
string sServerName = #"Answers1/Answers";
string sPassword = "xxxxxx";
//Creating the notes session
NotesSession session = new NotesSession();
session.Initialize(sPassword);
NotesDatabase NotesDb = session.GetDatabase(sServerName, sMailFile, false);
//If the database is not already open then open it.
if (!NotesDb.IsOpen)
{
NotesDb.Open();
}
calling session.GetDatabase() with the server name and path the the nsf file returns null which, apparently means it could not open the db.
I am running this code locally, against a Notes server called "Answers1/Answers". I am now thinking based on From the Notes server, the nsf files are located on a network fileshare of "NotesMail_FDrive\ARchives\xyz.nsf".
Is the server on which the file resides a Notes server or just a network share?
If it's a network share, you need the drive mapping, but sServerName would be "" to get to a "local" drive. I'm assuming Notesdata1 is a directory on X, so if it's the drive name, remove it.
string sMailFile = #"X:\Notesdata1\NotesMail\ARchives\scady.nsf";
string sServerName = #"";
If it's a Notes server AND Notesdata1 is the data directory for the Notes server, then
string sMailFile = #"NotesMail\ARchives\scady.nsf";
string sServerName = #"Answers1/Answers";
Sorry I didn't notice this on the first pass...
The value for sMailFile should not be "\10.10.10.71\notesdata1\NotesMail\ARchives\scady.nsf". The other two values that you have commented out are also wrong. The arguments for getDatabase are the Domino server's distinguished name, and a relative path. No server IP, no volume, and no "file:" prefix. Just something like this: "archives\scady.nsf". It should be exactly what you see for the path when you open up the database in your Notes client and bring up the database properties dialog.
Previous Answer
Your sServername variable contains the Domino server's distinguished name, as it should.
But why are you using File.Exists? The Domino server wants exclusive access to all of the files in its data tree. If you are actually successfully accessing the file on the Domino server via a filesystem call, then perhaps you are locking the Domino server out of accessing it.
But also: where are you running this code? Are you running it on the same computer, and under the same account that you normally use to read your email? Or on a different computer and account?

ASP Upload Component - Classic ASP

I have just moved a site from a dedicated server to a GoDaddy shared hosting account, and have just encountered loads of problems! One being with ASP Upload.
In Classic ASP, this is what I would normally do to upload files to my folder:
Set upload = Server.CreateObject("Persits.Upload")
uploadPath = Server.MapPath("../../files/photos/"&token_&"/")
upload.IgnoreNoPost = True
upload.Save(uploadPath)
Set upload = Nothing
But since moving to GoDaddy, I get this nasty message:
This feature has been disabled by the system administrator. Use SaveVirtual instead.
I went on to ASP Upload's website documentation and I could not find SaveVirtual, only SaveAsVirtual which is where I have become unstuck.
I tried using SaveAsVirtual but it threw an error stating that I was using a physical path and I should be using a virtual path! I really don't understand this and was hoping that somebody could put me straight. My website is now deemed broken and is offline, please help.
This is what I tried before the physical/virtual path error:
Set upload = Server.CreateObject("Persits.Upload")
uploadPath = Server.MapPath("../../files/photos/"&token_&"/")
upload.IgnoreNoPost = True
upload.SaveAsVirtual(uploadPath)
Set upload = Nothing
According to the docs, the method is named SaveVirtual. It does the Server.MapPath conversion for you.
So, try:
Set upload = Server.CreateObject("Persits.Upload")
uploadPath = "../../files/photos/"&token_&"/"
upload.IgnoreNoPost = True
upload.SaveVirtual(uploadPath)
Set upload = Nothing
You already set a folder path to upload not need use like this "server.mappath"
please use below of code.
Set Upload = Server.CreateObject("Persits.Upload" )
Upload.SetMaxSize 10000000 ' Maksimum dosya büyüklüğü Byte cinsinden
Upload.OverwriteFiles = True
Path = "../../duyurular/"
Count = Upload.SaveAsVirtual(Path)
for godaddy you have to go in and change the server folder permission to read/write. Otherwise you get that error message.
well I also get encounter with this problem, I just changed the folder privileges from Go-daddy Hosting server so Any one can read or Write file from specific location
Many Thanks
Ahsan Aziz Abbasi

VBscript - How do I change anonymous authentication settings for a specific site?

I'm writing a VBscript that I would like to alter the anyonymous authentication configuration for a specific site on my web server. However, I'm unsure of how this is done in the commit path. Currently, I am able to change the setting on a global scale, but I only want to target one particular site folder. My best guess was to simply include the site path at the end of MACHINE/WEBROOT/APPHOST.
'CHANGE ANONYMOUS AUTHENTICATION GLOBALLY (working code):
Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST")
anonymousAuthenticationSection.Properties.Item("enabled").Value = True
anonymousAuthenticationSection.Properties.Item("userName").Value = "myUser"
anonymousAuthenticationSection.Properties.Item("password").Value = "myPass"
adminManager.CommitChanges()
'MY BEST GUESS AT TARGETING A SPECIFIC SITE (returns error 80070005):
Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Sites/InsideFTL/Corp/redirects/netXposure")
The code that you have above should work, are you running it from an elevated command prompt?
You could also try to make sure that it is committing to ApplicationHost.config to make sure it is not a locking issue by setting CommitPath, and make sure that the identity under you are running the script has write access to it.
'CHANGE ANONYMOUS AUTHENTICATION For Default Web Site:
Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
anonymousAuthenticationSection.Properties.Item("enabled").Value = True
anonymousAuthenticationSection.Properties.Item("userName").Value = "myUser"
anonymousAuthenticationSection.Properties.Item("password").Value = "myPass"
adminManager.CommitChanges()

"The directory name is invalid" error on Process.Start?

I am writing a launcher program, and when I go to start the process I get the "The directory name is invalid" error. Here is the code that is launching the process:
Const DEBUG_ROOT = _
"Z:\Kiosk_JC\KioskSignIn.root\KioskSignIn\KioskSignIn\KioskSignIn\bin\Debug"
Dim oKiosk As New System.Diagnostics.Process
oKiosk.StartInfo.UserName = oEnc.Decrypt(Username)
oKiosk.StartInfo.Password = oEnc.DecryptSecure(Password)
oKiosk.StartInfo.Domain = oEnc.Decrypt(Domain)
''// The AddBS function appends a '\' to the passed string if it is not present
oKiosk.StartInfo.WorkingDirectory = AddBS(DEBUG_ROOT)
oKiosk.StartInfo.FileName = "KioskSignIn.exe"
oKiosk.StartInfo.UseShellExecute = False
Dim proc As Process = Nothing
proc = System.Diagnostics.Process.Start(oKiosk.StartInfo)
I saw on another question here that I needed to set the WorkingDirectory (before I started searching I was getting the error). Even though I have this property set, I am still getting the error. Any thoughts?
More info
I should also note that my Z:\ is a on my network. I have a function that resolves a path to UNC. When I ran this function on DEBUG_ROOT, I get the same error.
I tried moving the application to c:\kiosk. Same result. I am logged in as the user I am impersonating, so I have access to all shares and files.
Here is the link, for some reason the URL formating wants to consume all the text after the link is designated:
Referred Post
Mapped drives are per-user. You are likely starting the process with a different user.
Sounds like the process can't see the Z: drive or doesn't have security access. What user context does the app run under? Perhaps the Z: drive is not available in that context.
I got the same error as you do. most likely the user you use to run the process does not have access to specified resource (exe file)
try to move your exe to some other location and/or give your user access rights to the file.