Executing Win32 commands in RSH

Very often we get requests to setup environment where client will connect to Windows RSH server and the execute Windows commands in single line. In most if these scenarios; customers will report that this setup was working with SFU 3.5 and RSH; and now broken on Windows 2003 R2.

First of all, there is a major difference between the way we ship RSH components on SFU 3.5 and in Windows 2003 R2 (and future version). That is “Windows Remote Shell” has been removed from Windows 2003 r2 and we only give Interix RSH nowadays.

In Windows Remote Shell: The shell used to execute the command is windows command shell cmd.exe; whereas in Interix RSH: The shell used to execute the requested command is user’s Interix default login shell.

So, executing Windows commands in Windows Remote Shell was easy. The same commands do not work on Interix RSH.

One of the “workaround” is to use the win32 commands available in SUA installation directory. Basically we need to point to the different location of the win32 commands. on Windows 2003 R2 "/dev/fs/C/WINDOWS/SUA/usr/contrib/win32/bin" has most of the common win32 commands. BTW, to know about the syntax used in here you may refer to this blog.

With SUA on Windows 2003 R2 RSH Server:

rsh -l user1 <IP of Windows RSH Server> "/dev/fs/C/WINDOWS/SUA/usr/contrib/win32/bin/dir < /dev/null |cat"

... (output truncated)

trying normal rsh (/usr/bin/rsh)

 Volume in drive C has no label.

 Volume Serial Number is 9C96-F135

 Directory of C:\Documents and Settings\user1

08/06/2010 06:03 AM <DIR> .

08/06/2010 06:03 AM <DIR> ..

08/06/2010 06:03 AM 19 .rhosts

06/05/2009 03:13 AM <DIR> Desktop

08/05/2010 09:40 AM <DIR> Favorites

08/05/2010 09:40 AM <DIR> My Documents

06/05/2009 03:13 AM <DIR> Start Menu

06/05/2009 03:15 AM 0 Sti_Trace.log

               2 File(s) 19 bytes

               6 Dir(s) 3,425,800,192 bytes free

With SFU 3.5 + Interix Shell on Windows 2003 RSH Server (the location of win32 commands is different here):

rsh -l user2 <IP of Windows RSH Server> "/dev/fs/C/SFU/usr/contrib/win32/bin/dir < /dev/null |cat"

... (output truncated)

trying normal rsh (/usr/bin/rsh)

 Volume in drive C has no label.

 Volume Serial Number is FCDE-A450

 Directory of C:\Documents and Settings\user2

08/06/2010 08:39 AM <DIR> .

08/06/2010 08:39 AM <DIR> ..

08/06/2010 08:39 AM 19 .rhosts

               1 File(s) 19 bytes

               2 Dir(s) 130,558,615,552 bytes free

HTH