EldoS | Feel safer!

Software components for data protection, secure storage and transfer


Posted: 09/15/2008 08:41:19
by Ken Ivanov (Team)

Your modification is not correct, as you should create an instance of TElShellSSHSubsystemHandler class (not of TElCustomSSHSubsystemHandler). Please try to cast TElShellSSHSubsystemHandler to TElCustomSSHSubsystemHandler explicitly:

TElSSHSubsystemThread((TElCustomSSHSubsystemHandler)(new TElShellSSHSubsystemHandler(Connection, true)), Connection, true);
Posted: 09/15/2008 08:54:59
by Manfred Domandl (Basic support level)
Joined: 09/11/2008
Posts: 9

I changed as you have recommended.
Now I get this compile error:
"Fehler CS0246: Der Typ- oder Namespacename "TElShellSSHSubsystemHandler" konnte nicht gefunden werden. (Fehlt eine using-Direktive oder ein Assemblyverweis?)"

Is it possible to add an additional assambly?
Posted: 09/15/2008 10:52:34
by Ken Ivanov (Team)

Hmm, it's quite strange. We will try to reproduce the issue and get back to you as soon as possible.
Posted: 09/15/2008 12:07:49
by Ken Ivanov (Team)

Got it. TElShellSSHSubsystemHandler class has not been implemented for Compact Frameworks due to difficulties with redirecting process standard input and output streams.

You can implement TElShellSSHSubsystemHandler for CF yourself. In general, you should do the following:
a) create a descendant of TElCustomSSHSubsystemHandler and name it TElShellSSHSubsystemHandler,
b) override its HandlerType() method which will just return TSBSSHSubsystemHandlerType.shtSynchronous value,
c) override its Execute() method which will create the process with a needed name and run a read-write loop while the process is active. The code for desktop Framework follows:
procedure TElShellSSHSubsystemHandler.Execute;
  Buf : ByteArray;
  ChBuf : CharArray;
  StdOutReader, StdErrReader: Thread;
  cmd: string;
  Received: cardinal;
  S: string;
  Changed : boolean;
  SetLength(Buf, 8192);
  SetLength(ChBuf, 8192);
  if Length(Command) = 0 then
    cmd := GetEnvironmentVariable('COMSPEC')
    cmd := GetEnvironmentVariable('COMSPEC') + ' /c ' + Command;
  FProc := Process.Create;
  FProc.StartInfo.Filename := cmd;
  FProc.StartInfo.RedirectStandardInput := true;
  FProc.StartInfo.RedirectStandardOutput := true;
  FProc.StartInfo.RedirectStandardError := true;
  FProc.StartInfo.UseShellExecute := false;
  FProc.StartInfo.WindowStyle := ProcessWindowStyle.Hidden;
  FProc.StartInfo.CreateNoWindow := true;
  FSync := TElSharedResource.Create;
  if FProc.Start() then
      StdOutReader := Thread.Create(new ThreadStart(ProcessStdOutput));
      StdErrReader := Thread.Create(new ThreadStart(ProcessStdError));
        (not FProc.HasExited)
        and (not Terminated) and (Connected) do
        Changed := false;
        Received := ReceiveData(Buf, 0, Length(Buf));
        S := ConvLF(Buf, 0, Received);
        if Length(S) > 0 then
          Changed := true;
          if Length(FStdOutSpool) > 0 then
            SetLength(FStdOutSpool, 0);
            Changed := true;
          if Length(FStdErrSpool) > 0 then
            SetLength(FStdErrSpool, 0);
            Changed := true;
        if not Changed then
Posted: 09/16/2008 03:52:56
by Manfred Domandl (Basic support level)
Joined: 09/11/2008
Posts: 9

Thank you very much.
Now i will try to translate the provided Delphi code into C# code.
Posted: 09/16/2008 04:35:29
by Manfred Domandl (Basic support level)
Joined: 09/11/2008
Posts: 9

Ok, this will not work because this is although no Compact Framework (CF) code.
i.e: FProc.StartInfo.RedirectStandardInput does not exit in CF....
Posted: 09/16/2008 06:29:12
by Ken Ivanov (Team)

Yes -- those are the differences I have mentioned in the previous post.

Actually, there does exist an another way to implement input/output redirection -- by calling WinAPI process-related functions using P/Invoke.



Topic viewed 6990 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!