Standard output of an FTP process in Windows 8


hi everyone, need help.

i developed sw download data ethernet device using ftp protocol. since device doesn't react in right way o.s. api, way found interact using ftp.exe process inside sw, redirecting standard output , analyze output.

everything working fine under windows 7, first test windows 8 results in program failure.

after investigations, found out standard output changes, depending on operating system installed on pc program running.

here follows example of mean. first of all, run ftp.exe command line download file, redirecting standard output file, , response:

ftp> connesso 10.1.116.251.
open 10.1.116.251
220 cmx tcp/ip - remote ftp server (version 1.0) ready.
utente (10.1.116.251:(none)):
331 password required user.

230 user logged in, proceed.
ftp> session.tel
200 port command successful.
150 opening ascii mode data connection 'session.tel'.
226 transfer complete.
ftp: 1640 bytes received in secondi kbyte/sec)
ftp> 0.001640.00quit
221 goodbye.

it differs little windows 7 windows 8, results same.

then, piece of code used test ftp response in custom application:

string ftpcommandsfilepath = path.combine(path.gettemppath(), "ftp.txt");  using (streamwriter writer = new streamwriter(ftpcommandsfilepath))  {  	writer.write("open 10.1.116.251\nuser\npassword\nget session.tel\nquit\n");  }    string output = string.empty;    try  {  	process ftpprocess = new process();  	ftpprocess.startinfo.workingdirectory = path.gettemppath();  	ftpprocess.startinfo.filename = path.combine(environment.getfolderpath(environment.specialfolder.system), "ftp.exe");  	ftpprocess.startinfo.arguments = string.format("-v -s:{0}", "ftp.txt");  	ftpprocess.startinfo.useshellexecute = false;  	ftpprocess.startinfo.redirectstandardoutput = true;  	ftpprocess.startinfo.createnowindow = true;  	ftpprocess.start();  				  	using (streamreader reader = ftpprocess.standardoutput)  	{  		output = reader.readtoend();  	}    	messagebox.show(output);  }  catch  {}

this result see when run program under windows 7:

and it's same of console output.

this see under windows 8:

all non prompt messages missing (even if file downloaded correctly)! in case, i'm not able detect neither "226 tansfer complete" message nor size of file (or other information).

i tried change process.startinfo.arguments, adding explicite redirect file ("> out.txt"), seems doesn't work.

anyone know if i'm doing wrong, or if there 1 or more o.s. settings change behaviour?

thanks lot,

marco

hi bob, reply.

i tried ftpwebrequest class before starting using method process class (the 1 use within code), problem ethernet device made our own, has problems when requests made using .net fx classes (for example, download interrupted, without clear reason).

by way, found out interesting thing: within code turn on "-v" switch of ftp.exe program, 1 disables server response. that's reason why i'm not seeing ftp response under windows 8.

after noting this, wondered why used "-v" switch when wrote code (some years ago) , why code runs under windows xp , windows 7 no problems, , found out funny thing: if use "-v" switch "-s" 1 (that switch specify commands execute written within text file), under windows 7 seems acts reverse expected! mean, if type "ftp -v -s..." , on, server messages shown, while if use "ftp -s..." without "-v" switch, server messages cut. , behaviour differs 1 under windows 8.

so, think i'll made check o.s. version within code, adapting ftp process arguments depending on o.s. version.

i hope useful having problem similar mine.

thanks again,

marco



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'