Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting FTP problem

Status
Not open for further replies.

wcburton

IS-IT--Management
Apr 4, 2002
269
US
I am trying to automate a weekly FTP download. The site is setup to access the ftp files from a web page. You put in the filename in a form and the site will kickoff the ftp download. I have tried using the ftp.exe from command prompt and always get a connect error. The site is locked down to prevent browsing of files on the ftp server. You must know the filename you need.

The command kicked off by the web page is of this format:
ftp://user:pwd@host:21/file.zip

The only way I have been able to script this is by using InternetExplorer.Application and sendkeys.

Code:
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")

Set objShell = CreateObject("WScript.Shell")

objExplorer.Navigate  "ftp://user:pwd@host:21/file.ZIP"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 1000
objExplorer.Height = 500
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1


WScript.sleep 3000
objShell.AppActivate "File Download"
WScript.sleep 300
objShell.SendKeys "{enter}"
wscript.sleep 1000
objShell.SendKeys "new file name and path.zip"
objShell.SendKeys "{enter}"
objShell.SendKeys "{enter}"

This does not work if the PC is locked because sendkeys cannot issue the replies to the download prompts from IE.

Can anyone help me get this working? Are there other options to supress the download prompts? (I could rename the downloaded file later.)
Or could someone point me in a different direction that does not use IE?
 
Look up ftp (exe) utility. (Also you are not going to use wscript.sleep native to wscript.exe inside browser client script.) Then, if you like the browser's environment, take the working script with ftp (exe) to hta.
 
I previously stated that I have not been able to get this site to work with ftp.exe. I always get a connect error. I do know ftp and the option to build a text file with the commands listed inside. I also tried the -n option to supress the auto login but I always get "connect: unkown error number".

You did remind to test something else though and it may be a network problem that prevents connect with ftp. I will try something later from my home PC and see if it connects.

In regard to your other comment, why would I not use sleep in the browser script? Or are you saying that if I switch to ftp that I will not need to use the sleep command?

 
Okay, you were not using .sleep in a browser environment. So, you can ignore that remark.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top