Solved

FTP, AS/400 and VB

Posted on 2004-03-30
7
628 Views
Last Modified: 2012-06-21
Does anyone have simple sample code in VB that will allow me to download a file from the AS/400 using FTP.
The file name on the AS/400 is known and will not change and also the file name on the PC will not change as well. It's just a strait copy without any user intervention.

Can someone please help me.

Thanks.
0
Comment
Question by:viselli
  • 5
7 Comments
 
LVL 7

Expert Comment

by:ramesh12
ID: 10716677
Use something like this


Dim WshShell, curDir, wShell, file

Set wShell = WScript.CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.OpenTextFile("sometextfile.txt",2,True)

file = InputBox ("Which file will you upload?","File adder")

OutPutFile.WriteLine "open [ftp server]" 'Connects to the ftp server
OutPutFile.WriteLine "[username]"
OutPutFile.WriteLine "[password]"
OutPutFile.WriteLine "Lcd [folder]"
OutPutFile.WriteLine "Get " & file 'Adds the file to the ftp server
OutPutFile.WriteLine "bye" 'Quit.
OutPutFile.Close



Set wShell = Nothing
Set WshShell = Nothing
Set FileSystem = Nothing
Set OutPutFile = Nothing
WScript.Quit(0)
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10716786
Oops sorry

Here is the code again

Dim WshShell, curDir, wShell, file

Set wShell = WScript.CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.OpenTextFile("sometextfile.txt",2,True)

file = InputBox ("Which file will you upload?","File adder")

OutPutFile.WriteLine "open [ftp server]" 'Connects to the ftp server
OutPutFile.WriteLine "[username]"
OutPutFile.WriteLine "[password]"
OutPutFile.WriteLine "cd [folder]"
OutPutFile.WriteLine "put " & file 'Adds the file to the ftp server
OutPutFile.WriteLine "bye" 'Quit.
OutPutFile.Close

curDir = WshShell.CurrentDirectory
wShell.Open curDir & "\batfile.bat"

Set wShell = Nothing
Set WshShell = Nothing
Set FileSystem = Nothing
Set OutPutFile = Nothing
WScript.Quit(0)
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10716787
Oops sorry

Here is the code again

Dim WshShell, curDir, wShell, file

Set wShell = WScript.CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.OpenTextFile("sometextfile.txt",2,True)

file = InputBox ("Which file will you upload?","File adder")

OutPutFile.WriteLine "open [ftp server]" 'Connects to the ftp server
OutPutFile.WriteLine "[username]"
OutPutFile.WriteLine "[password]"
OutPutFile.WriteLine "cd [folder]"
OutPutFile.WriteLine "put " & file 'Adds the file to the ftp server
OutPutFile.WriteLine "bye" 'Quit.
OutPutFile.Close

curDir = WshShell.CurrentDirectory
wShell.Open curDir & "\batfile.bat"

Set wShell = Nothing
Set WshShell = Nothing
Set FileSystem = Nothing
Set OutPutFile = Nothing
WScript.Quit(0)
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Expert Comment

by:ramesh12
ID: 10716798
Sorry for the double post.
0
 

Author Comment

by:viselli
ID: 10716857
Thanks for your prompt response.

When I try this I get the message "Expected variable or procedure, not module" on the line that read "Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")"

Unsure what to do this this?

Thanks.
0
 
LVL 5

Expert Comment

by:g0rath
ID: 10716873
0
 
LVL 7

Accepted Solution

by:
ramesh12 earned 125 total points
ID: 10716932
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now