Solved

FTP, AS/400 and VB

Posted on 2004-03-30
7
631 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

932 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

11 Experts available now in Live!

Get 1:1 Help Now