[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Why only getting partial StandardOutput of a "Process.Started" FTP called from VB.NET?

Posted on 2004-08-30
8
Medium Priority
?
397 Views
Last Modified: 2008-01-09
I have a VB.NET application that does an FTP and redirects the Standard Output to a file.  I only get partial data from the StandardOutput. The missing contents are the actual FTP replies (like "150 Open...." and "226 Transfer.....").
I've scoured this site and the internet, and have seen several others ask this similar question but none have any answers.

All is well is most situations, except of course in the one environment where the code will run in Production! I perform this FTP Routine two times in my code, sending output files to two different mainframe IPs. In my Dev environment (which happens to be XP), all is hunky-dorey for both routines; I get my desired reply codes.  In my Test environment (which happens to be 2003), all is hunkey-dorey for one routine - the other in-house mainframe box does not produce the reply codes in the piped output log. However, when I do an FTP from the command prompt (in both Dev and Test environs), the Reply Codes are indeed there.

What's the .NET mystery? I suspect it's .NET and not the mainframe since all other combos work just fine.

Here's a code snippet:

FTPLabel:
            Dim FixedLiteral As String = FileParam4
            Dim DOS As New Process
            Dim pinfo As New ProcessStartInfo("ftp.exe")
            pinfo.Arguments = "-n -d -s:"
            pinfo.Arguments += FixedLiteral
            pinfo.RedirectStandardOutput = True    ' set to "true" to enable logging
            pinfo.RedirectStandardError = False
            pinfo.UseShellExecute = False     ' set to true to make silent/background

            ' Execute the process
            DOS = Process.Start(pinfo)
            If DOS.Start() Then
                ' Create the file for storing the output of the process
                Dim outfile As New System.IO.StreamWriter(FileParam5)
                outfile.Write(DOS.StandardOutput.ReadToEnd)
                ' Make sure the process has completed
                DOS.WaitForExit()
                ' Dump all the output from the process into the file
                'outfile.Write(DOS.StandardOutput.ReadToEnd)   'original line and location
                'outfile.WriteLine(DOS.StandardOutput.ReadToEnd)
                outfile.Close()
            End If
            'After the FTP process is done, I must open up the log file and check for the string "226 File received ok". If I don't find it, then I will have to try the FTP again.
            mySRftp = New StreamReader(FileParam5)
            mySRText = mySRftp.ReadToEnd()
            If InStr(mySRText, "226 Transfer completed") > 0 Then
                'Remove the concatenated ftp'ed file.
                File.Delete(Localtitle)
            Else
                BadAttemptCnt += 1
                If BadAttemptCnt < 4 Then
                    SendFTPEmail(Localtitle, BadAttemptCnt)
                    mySRftp.Close()
                    GoTo FTpLabel
                End If
            End If

This is the Output that is produced in DEV, that I want to see on the TEST box:

ftp> Connected to 162.xxx.xxx.x.
open 162.xxx.xxx.x
220 Upstanding Systems FTP Server version 70.144.48 ready.
ftp> ---> user XXXXXX
USER XXXXXX
331 User name is okay; need password.
--->
PASS XXXXXXXX
230 User logged in, proceed.
ftp> ftp>
---> ascii
TYPE A
200 Representation Type is ASCII Non-print.
ftp> ---> quote SITE RECL 770
SITE RECL 770
200 recordLen is 770 Characters.
ftp> ---> put C:\inetpub\wwwroot\Joseph\OutgoingFdleMerge770\ConcatFile.txt 00000552
PORT 162,xxx,xxx,xxx,13,155
200 PORT command successful.
---> STOR 00000552
150 Opening data connection for 00000552 (162.xxx.xxx.xxx,3483).
226 Transfer completed to 00000552 ON PROGRAMMING.
ftp: 4632 bytes sent in 0.00Seconds 4632000.00Kbytes/sec.

ftp> ---> quit
QUIT
221 Goodbye.

This is the problematic output that I see on the TEST box:

---> open 162.xxx.xxx.x
user XXXXXX
USER XXXXXX
--->
PASS XXXXXXX
--->
ascii
TYPE A
---> quote SITE RECL 770
SITE RECL 770
---> put D:\Inetpub\wwwroot\Joseph\OutgoingFdleMerge770\ConcatFile.txt 00000554
PORT 162,xxx,xx,xx,5,29
---> STOR 00000554
---> quit
QUIT


0
Comment
Question by:bigsplash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 

Author Comment

by:bigsplash
ID: 11934918
P.S.   I tried the debug switch, as such  ---- pinfo.Arguments = "-n -d -s:" ----  since somebody else on another forum seemed to have success with this option. In or out, it doesn't work for me.

Also, I failed to mention that the FTP "Put" command itself is performing sucessfully.
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 1600 total points
ID: 11935304
               outfile.Write(DOS.StandardOutput.ReadToEnd)
                ' Make sure the process has completed
                DOS.WaitForExit()

this is definately backwards.
0
 

Author Comment

by:bigsplash
ID: 11935413
Yes, I thought so myself..... I just happened to see it written out that way on some site and tried it..... I've changed it back, yet no luck.
If DOS.Start() Then
                ' Create the file for storing the output of the process
                Dim outfile As New System.IO.StreamWriter(FileParam5)
                ' Make sure the process has completed
                DOS.WaitForExit()
                ' Dump all the output from the process into the file
                outfile.Write(DOS.StandardOutput.ReadToEnd)   'original line and location
                outfile.Close()
            End If
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 400 total points
ID: 11936137
Is there any Unicode in the string?  You can write unicode:

Dim outfile As New System.IO.StreamWriter(FileParam5, System.Text.Encoding.Unicode)

Bob
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1600 total points
ID: 11936147
could the status be being written to standard error instead of standard out ? just a thought.
0
 

Author Comment

by:bigsplash
ID: 11936413
No additional data is written when Unicode is specified.  :-(

Interesting thought about the StandardError.  I created and wrote to this file too, and nope - it's blank.

A friend just e-mailed this link to me http://www.dotnet247.com/247reference/a.aspx?u=http://support.microsoft.com/
default.aspx?scid=kb;EN-US;832679.   It's apparently a way to use ftp managed .NET code. Long article..... I may try this tomorrow.
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 1600 total points
ID: 11936482
there are quite a few managed ftp libraries

0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 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