Z
Zenon
I have a C# application which interacts with an HP UNIX box via PSFTP.
I have run in to a problem where the maximum amount of characters I can
redirect is 1024. This number leads me to believe that it is not
random and perhaps there is some flushing that needs to occur before I
can read more. I couldn't find anything about the 1024 char limit
anywhere. Is anyone familiar with such a thing, or am I just doing
something wrong in my code? The pertinent lines are included here:
private ProcessStartInfo compileInfo = new ProcessStartInfo();
private Process compileProcess;
compileInfo.RedirectStandardInput = true;
compileInfo.RedirectStandardOutput = true;
compileInfo.UseShellExecute = false;
compileInfo.CreateNoWindow = true;
compileInfo.FileName = "psftp.exe";
compileInfo.Arguments = userName;
compileProcess = Process.Start(compileInfo);
compileProcess.StandardInput.WriteLine(password);
loggedIn = true;
string tb = "";
if (compileProcess.StandardOutput.ReadLine() != "")
{
tb = compileProcess.StandardOutput.ReadLine();
setTextBoxStatus(tb);
compileProcess.StandardInput.WriteLine("pwd");
tb = compileProcess.StandardOutput.ReadLine();
createTreeViewUX(tb);
}
compileProcess.StandardInput.WriteLine("dir");
char[] endR = new char[1024];
compileProcess.StandardOutput.Read(endR, 0, 1024);
compileProcess.StandardOutput.Read(endR, 0, 1024);
int f = 0;
f = compileProcess.StandardOutput.Peek();
compileProcess.StandardOutput.Read(endRT, 0, 1);
Here is what should be redirected
Listing directory /home/login1
drwx------ 5 login1 users 1024 Feb 7 14:35 .
drwxr-xr-x 15 login2 users 1024 Feb 7 11:01 ..
-rw------- 1 login1 users 0 Feb 6 15:46 .ICEauthority
-rw------- 1 login1 users 73 Feb 6 14:54 .TTauthority
-rw------- 1 login1 users 102 Feb 6 14:54 .Xauthority
.... more files removed for brevity ...
drwxrwxrwx 3 login1 users 96 Feb 16 16:25 tempdir
-rw-r--r-- 1 login1 users 382 Feb 7 11:05 test
psftp>
the first read line, compileProcess.StandardOutput.Read(endR, 0, 1024);
gets the first line "Listing directory /home/login1" fine
the second read gets 1024 chars of the ls command output right up until
about half way through the last line, which is 1024 chars into the
output.
the Peek statement (or read or anything else) fails when I try to look
past this point. Any ideas?
thanks
I have run in to a problem where the maximum amount of characters I can
redirect is 1024. This number leads me to believe that it is not
random and perhaps there is some flushing that needs to occur before I
can read more. I couldn't find anything about the 1024 char limit
anywhere. Is anyone familiar with such a thing, or am I just doing
something wrong in my code? The pertinent lines are included here:
private ProcessStartInfo compileInfo = new ProcessStartInfo();
private Process compileProcess;
compileInfo.RedirectStandardInput = true;
compileInfo.RedirectStandardOutput = true;
compileInfo.UseShellExecute = false;
compileInfo.CreateNoWindow = true;
compileInfo.FileName = "psftp.exe";
compileInfo.Arguments = userName;
compileProcess = Process.Start(compileInfo);
compileProcess.StandardInput.WriteLine(password);
loggedIn = true;
string tb = "";
if (compileProcess.StandardOutput.ReadLine() != "")
{
tb = compileProcess.StandardOutput.ReadLine();
setTextBoxStatus(tb);
compileProcess.StandardInput.WriteLine("pwd");
tb = compileProcess.StandardOutput.ReadLine();
createTreeViewUX(tb);
}
compileProcess.StandardInput.WriteLine("dir");
char[] endR = new char[1024];
compileProcess.StandardOutput.Read(endR, 0, 1024);
compileProcess.StandardOutput.Read(endR, 0, 1024);
int f = 0;
f = compileProcess.StandardOutput.Peek();
compileProcess.StandardOutput.Read(endRT, 0, 1);
Here is what should be redirected
Listing directory /home/login1
drwx------ 5 login1 users 1024 Feb 7 14:35 .
drwxr-xr-x 15 login2 users 1024 Feb 7 11:01 ..
-rw------- 1 login1 users 0 Feb 6 15:46 .ICEauthority
-rw------- 1 login1 users 73 Feb 6 14:54 .TTauthority
-rw------- 1 login1 users 102 Feb 6 14:54 .Xauthority
.... more files removed for brevity ...
drwxrwxrwx 3 login1 users 96 Feb 16 16:25 tempdir
-rw-r--r-- 1 login1 users 382 Feb 7 11:05 test
psftp>
the first read line, compileProcess.StandardOutput.Read(endR, 0, 1024);
gets the first line "Listing directory /home/login1" fine
the second read gets 1024 chars of the ls command output right up until
about half way through the last line, which is 1024 chars into the
output.
the Peek statement (or read or anything else) fails when I try to look
past this point. Any ideas?
thanks