viselli
asked on
FTP, AS/400 and VB
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.
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.
Oops sorry
Here is the code again
Dim WshShell, curDir, wShell, file
Set wShell = WScript.CreateObject("Shel l.Applicat ion")
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
Set FileSystem = WScript.CreateObject("Scri pting.File SystemObje ct")
Set OutPutFile = FileSystem.OpenTextFile("s ometextfil e.txt",2,T rue)
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)
Here is the code again
Dim WshShell, curDir, wShell, file
Set wShell = WScript.CreateObject("Shel
Set WshShell = WScript.CreateObject("WScr
Set FileSystem = WScript.CreateObject("Scri
Set OutPutFile = FileSystem.OpenTextFile("s
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)
Oops sorry
Here is the code again
Dim WshShell, curDir, wShell, file
Set wShell = WScript.CreateObject("Shel l.Applicat ion")
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
Set FileSystem = WScript.CreateObject("Scri pting.File SystemObje ct")
Set OutPutFile = FileSystem.OpenTextFile("s ometextfil e.txt",2,T rue)
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)
Here is the code again
Dim WshShell, curDir, wShell, file
Set wShell = WScript.CreateObject("Shel
Set WshShell = WScript.CreateObject("WScr
Set FileSystem = WScript.CreateObject("Scri
Set OutPutFile = FileSystem.OpenTextFile("s
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)
Sorry for the double post.
ASKER
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("Scri pting.File SystemObje ct")"
Unsure what to do this this?
Thanks.
When I try this I get the message "Expected variable or procedure, not module" on the line that read "Set FileSystem = WScript.CreateObject("Scri
Unsure what to do this this?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim WshShell, curDir, wShell, file
Set wShell = WScript.CreateObject("Shel
Set WshShell = WScript.CreateObject("WScr
Set FileSystem = WScript.CreateObject("Scri
Set OutPutFile = FileSystem.OpenTextFile("s
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)