Version 3 of remote execution using tcl and Pcom

Updated 2003-10-13 18:56:04

started by Theo Verelst

Pcom is a small package intended to offer one to one chat-like contact and back and forth file transfer with straightforward socket connections and adjustable port number, which also allows remote (tcl/tk) command execution.

The tcl exec command executes an external program on the same machine under the conditions of the current operating system. Under windows, linux and unix, the OS has a natural way of dealing with command line based program invokation, maybe on the madIntosh that can be done similarly, my memory escapes me on the subject (I do remember writing scripts).

The commands take in principle similar list form as under tcl, first element of the space seperated list is the command name, the rest options or arguments. In a shell a PATH needs to be taken into account, which points to the executable files on the disc, which is not the same under tcl. Also, list element seperation, and escape characters vary under tcl, *n?x, and windows, and as it happens, cygwin under windows.

To experiment with the exec command, start tcl or wish in the way you normally would, or the way it would automatically startup maybe, meaning from the same directory, environment and user rights, and make sure the console can be used, under windows and macIntosh (at least several verions ago) that is possible through:

   console show

under linux/unix, you may want to use the unixconsole script (which is on the wiki somewhere) to get a similar console (start it as first script, before other applications), now start by finding out wether the exec command can be used with some standart, simple shell commands, like

   exec pwd

on *n*x, or

   exec cmd /c dir

On a modern windows. On the older version, I'm sure one must use command(.com) and maybe capitals. The /c is to indicate the following argument(s) are to be interpreted as command. Paths on windows for the arguments should be in backward slash form, they don't get translated.

On windows I prefer to have a recent powerfull version of cygwin around, which takes some download time and moderate disc space, but leaves you with a useable unix emulation and strong bash shell as it now also is in use on Linux.I have a changed disc organisation with akward or absent original cygwin paths/registry information, but I can still go to the partition where it is, go to the bin direction (with all the executables) and for instance

   exec ./bash -c "./ls -F /home/someuser"

Which would list the contents of the home directory of someuser in a formatted form. Cygwin lets you use unix style slashes, change parition by /cygdrive/c/ instead of c:/ , normally.

From pcom, you can in the latest version (see pcom ... page) in the second entry from above, or in the normal (upper) text/message typing entry use the prefix DO_TCL, which will make the rest of that line executed as a tcl command on the other pcom side.

I use this (locally, but it works across the internet, too, preferably over a secure connection) to start an xwindows application which ends up on the other side of the pcom connection. That is on one side of a connected (symmetrical) pcom pair, I type for instance:

   DO_TCL exec c:/cygwin/bin/bash -c "/usr/X11R6/bin/xterm -fn '-adobe-courier-*-r-*-*-*-140-*-*-*-*-*-*' -rightbar -sb -fg white -bg black  -display amachine.mshome.net:0 " &

Which on the other side executes a tcl exec command which starts a bash spawned X terminal, which gets a display name of the machine I'm on, where the first pcom is. So I don't need inetd running, prevent security loopholes and login rights hassle, which is a drag on windows, normally, and can get a xterminal with a remote bash shell started up at any point as long as I can connect to the target machine to a running pcom. Handy when the machines are apart.

TO inquire which processes are running, I don't know what windows command to use by heart, but under cygwin, we can use

   exec ps -aef

to get a full list of the cygwin started programs, whereas

   exec ps -W

gives a windows running program list. The first element on a line is PID. To kill a process under cygwin:

   exec kill "-KILL <PID>"

otherwise

   exec tskill <WPID>