PDA

Click to See Complete Forum and Search --> : FTP or Giving an Environment to Spawned Cmd.exe's


ptgThug
May 24th, 2000, 01:52 AM
This is a lenghty post, I understand, but my problem requires a healthy level of detail to convey, and I'm sure requires a formidable knowledge to address.

What I want to ultimately do is FTP a file to an OS/390 mainframe, trigger a JCL script, and download the results. Since the mainframe is EBCDIC (instead of ANSI ASCII), the FTP session requires a SITE QUOTE command to do the conversion, another one to allow me to trigger the JCL job, and another one to set the file access back to normal.

I can find VB's API calls for FTP put and get, but I need to use site. If there is an API call for that, then all of my problems are solved.

Since I don't know of one, I am spawning a CMD /C and telling it to run an ftp /s with an input file. Since the CMD starts with no evironmental variables set (such as path), I have to explicitly say C:\Winnt\System32\ftp.exe /s et al. Spawning the CMD this way (with CreateProcess&()), I wait for it to exit (using the handle returned in CreateProcess&() in WaitForSingleObject&()).

To trouble shoot, I am using CMD /K and setting the focus to normal (calling the CMD with CreateProcess&()). I get to see the ftp session say, "mainframe.usps.gov: Unknown host". I fear that it is not resolving the name lookup correctly (if that makes any sense).

I'm hoping someone has an idea, and I'm including a bit of code if it will help:


Dim strCmdLine As String
strCmdLine = "C:\WINNT\System32\cmd.exe /K C:\WINNT\system32\ftp.exe -n -s:" & App.Path & "\ftp.txt mainframe.usps.gov"

lngRETVAL = CreateProcess&(vbNullString, strCmdLine, 0, 0, 1, NORMAL_PRIORITY_CLASS, 0&, vbNullString, udtStartupInfo, udtProcessInfo)
lngRETVAL = WaitForSingleObject&(udtProcessInfo.hProcess, -1)
lngRETVAL = CloseHandle&(udtProcessInfo.hProcess)


If anyone has any specific questions, and think they can help, just ask. I can't send but so much of the project since all the machines are hidden behind the firewall and I do have proprietary interests to consider (but I am open source at heart).

Many thanks in advance,
Travis

May 25th, 2000, 05:56 PM
You could try to open the site inside the ftp.txt script instead of from the command line(guess it does work inside ftp right?).


open mainframe.usps.gov
user me
pass ***
......
Do stuff
......
close
bye

ptgThug
May 25th, 2000, 07:56 PM
And that is what I do. I guess I didn't do a good job of explaining that before.

And that worked when I was doing all of this with a Perl script. Now I get Unknown host:mainframe.usps.gov. It does not appear to be doing any name resolution.

I'm still playing with stuff. It likes IP addresses, but I get unknown socket error if I use 56.x.x.x or bad address if I use 56.x.x.x:21.

-Travis