tbc@hp-lsd.HP.COM (Tim Chambers) (08/03/89)
In article dbainbri@ics.uci.edu (David Bainbridge) writes: > Is it possible to open a shell in an X-window... I have wanted such a beast, too. I would like a "command dispatcher" that opens a window for each command line executed. Although not exactly what I want, pam(1), available as a standard command on HP-UX, is an example of such an alternative to terminal-based shells. I quote the man page for examples: Pam is a program that provides a friendlier, less intimidating means of communication between HP-UX and system users. It provides many of the traditional capabilities supported by other shell programs, such as executing commands as foreground processes (that is, where you must wait until one command has been completed before the system accepts the next command) or background processes (where the command runs in the background while you perform other tasks in the foreground). ... In a windowed system, interactive commands are treated as background processes (&) unless a semicolon is present at the end of the line. Standard Input, Output, and Error Files The standard input, output, and error of a command can be redirected using the following syntax: ... (This is the feature *I* like about it!) # name [For windowed systems only] Use the named window as standard input, output and error for the command. If the window doesn't exist, a window is created. Specific redirection of I/O with >, >>, <, |, ^, or ^^ overrides any redirection specified with "#". One undesirable feature of pam is that it was designed to run on *either* a terminal *or* in a windowed environment, so pam itself consumes an xterm window just like sh(1) or ksh(1) does. I think David wants a shell that is independent of xterm for I/O. I know *I* do. The following response is the complete man page for pam, in case I've piqued your curiosity. A caveat: The multi-window feature may be broken for HP-UX 6.5. I liked it under 6.2, though. I chose not to complain since it might be pilot error on my part; *but*, if you are an HP trade customer, try pam as a result of this posting, and find defects, then COMPLAIN TO YOUR HP SALES REPRESENTATIVE! (I hope there aren't negative reactions to this recommendation, but please post a separate note in comp.sys.hp if you have comments pro or con rather than drifting here -- HP customer service would be an interesting topic of notes conversation on its own.) Disclaimer: I work on host-based instruction set debugger/simulators of mainstream microprocessors and am not making this posting as an HP employee who has a vested interest in pushing the command recommended here. - Tim Chambers
jcb@frisbee.Sun.COM (Jim Becker) (08/04/89)
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes:
->> Is it possible to open a shell in an X-window.
->I know of not way to do this with or without a toolkit. There is nothing
->on the Core distribution that supports this type of operation, short
->of ripping apart xterm to get the code that you would need.
I believe that it would be very simple to add a little functionality
to xterm that would allow this. If there was a parameter added that
allowed the XID of the desired (existent) window to be used instead of
a freshly created one then xterm could run within the confines of
another's window. Since windows are a sharable resource in the X
world this would work correctly.
The programmatic invokation of xterm as a child process would then
define the working window for xterm to do it's stuff in.
For example, "xterm -window 0x9000f2" would start up xterm and use the
pre-created window with XID 0x9000f2 rather than creating a fresh
window for use. Since it will still ask for the same events, and get
them with a different display connection, it will function as if it
were a child of the root or window manager. (There may be some
problems with window properties or other nits, but I would assume that
they could be hashed out.)
In general this is an underlying strength of The X Window System that
hasn't gotten any press. If there is a defined method used to tell a
single window application the window in which to live, thus logically
reparenting it, one automatically ends up with something similiar to a
multi-threaded environment. Each process could take care or it's own
business in it's window, getting and processing events of interest,
whilst adding to the whole of the UI appearance and behaviour.
Seems like the buzz words `Object-Oriented' and `Multi-Threaded' could
actually take on some real-life application with the use of this
concept. :-) If this approach was taken, creating entire building
blocks and combining them into more complex wholes, the X community
could offer lots of software in a short period of time. [I know that
this is an existing goal, and rws was just kidding about widgets
being created to sell more memory.. :^) -- at least I think.. ]
-> Chris D. Peterson
-> MIT X Consortium
-Jim Becker jcb@sun.com
tbc@hp-lsd.HP.COM (Tim Chambers) (08/04/89)
PAM(1) HP-UX PAM(1) NAME pam - Personal Applications Manager, a visual shell SYNOPSIS pam [ -c args ... ] DESCRIPTION Pam is a program that provides a friendlier, less intimidating means of communication between HP-UX and system users. It provides many of the traditional capabilities supported by other shell programs, such as executing commands as foreground processes (that is, where you must wait until one command has been completed before the system accepts the next command) or background processes (where the command runs in the background while you perform other tasks in the foreground). Pam also supports other useful capabilities such as using substituted files instead of standard input and standard output, pipelining several processes into a single command, and handling shell scripts and programs. Pam maintains a continuous display of the open folder (current directory), and makes use of windowing and mouse I/O facilities when they are available on the system. Display The pam display has two parts. The top two lines are called the command area, while the remainder of the display is the folder (directory) area. The first line in the command area displays messages (such as prompts and errors) from the system to the user, while the second line displays input commands and text from the user to the system. Pam maintains a buffer of 20 command lines. You can use shifted arrow keys, BACK SPACE, INSERT CHARACTER, and DELETE CHARACTER to access and edit any existing current or previous command line in the 20-line command buffer. For example, each time you press SHIFT-UP ARROW, the next previous command line in the buffer is displayed. The folder (lower) area is used by pam to display files that reside in the currently open folder (that is, the current directory). One of the file names displayed in the folder area is highlighted. This highlighted file name identifies which file in the folder should be used as a file name parameter for pam commands that are invoked using the pam menu. The highlighted file name can be changed by using TAB, SHIFT-TAB and arrow keys. Commands Hewlett-Packard Company - 1 - Aug 3, 1989 PAM(1) HP-UX PAM(1) A command is a sequence of words separated by blanks. In general, the first word is the name of the command, and the words that follow are passed as arguments to the invoked command. Two or more commands (together with their associated arguments, if any) separated by a vertical bar (|) form a pipeline. To pass data between commands in a pipeline, the standard output from one command is connected to the standard input of the next command in the pipeline. To force pam to complete execution of the current command or pipeline before running another command, place a semicolon (;) at the end of the line. If you prefer to perform other tasks while the command or pipeline is being executed, run the first command as a "background" process by adding an ampersand (&) at the end of the command line. Pam then starts the command, and without waiting for completion, returns for your next instruction. In a windowed system, interactive commands are treated as background processes (&) unless a semicolon is present at the end of the line. In non-windowed systems, commands taken from a script or from interactive commands are run to completion before the next command is accepted for execution (;) unless an ampersand is present at the end of the command line. Sequences of more than one command or pipeline can be joined on a single command line by placing a semicolon or ampersand (but not both) between each adjacent pair of commands or pipelines in the line. In such constructs, commands separated by semicolon (;) are executed in sequence (that is, the first command is run to completion before the next is begun). Commands separated by ampersand (&) are executed simultaneously on a timesharing basis. (However, this does not necessarily result in the most efficient use of computer resources due to timesharing overhead as sharing processes compete for processor time.) Note that when semicolon or ampersand is used to separate commands, standard output from one command is not automatically connected to standard input for the next. When data must be passed between successive commands or programs, use the pipeline connector (|) or redirect standard output and input to and from a specified file. Pam runs commands based on the file type of the command name: program (executable) Hewlett-Packard Company - 2 - Aug 3, 1989 PAM(1) HP-UX PAM(1) The command name is run (exec'ed) or, if it is a shell script, the commands in the script are run. folder (directory) The command name (folder) becomes the new open folder. This is equivalent to cd folder. data (non-executable) The command name (data file) is displayed one page at a time. Standard Input, Output, and Error Files The standard input, output, and error of a command can be redirected using the following syntax: < name Use the file name as standard input for the command. > name Use the file name as standard output for the command. >> name Use the file name as standard output for the command, but concatenate the output to the end of the file. ^ name Use the file name as standard error for the command. ^^ name Use the file name as standard error for the command, but concatenate the output to the current end of the file, if it exists. # name [For windowed systems only] Use the named window as standard input, output and error for the command. If the window doesn't exist, a window is created. Specific redirection of I/O with >, >>, <, |, ^, or ^^ overrides any redirection specified with "#". I/O redirection is possible only with an associated command. Multiple redirections of standard input, output, and error associated with a command are not allowed. The I/O redirection can be placed anywhere in the command. If a command is followed by "&" (background process), the default standard input for the command is the empty file Hewlett-Packard Company - 3 - Aug 3, 1989 PAM(1) HP-UX PAM(1) /dev/null. Using Patterns to Represent Filenames Each word in the command line (command name, parameter, redirection file name, window name) is scanned for the characters *, ?, and [. If one of these characters appears, the word is treated as a pattern that represents more than one filename. Pam replaces the pattern word with alphabetically sorted filenames corresponding to the pattern. If no file name is found that matches the pattern, the word is left unchanged. A period character (.) at the start of a filename or immediately following a /, as well as the character / itself, must be matched explicitly. * Matches any string, including the null string. ? Matches any single character. [...] Matches any one of the enclosed characters. A pair of characters separated by a hyphen (-) matches any character lexically between the pair, inclusive. A NOT operator (!) can be specified immediately following the left bracket to match any single character not enclosed in the brackets. Quoting Characters can be quoted on the pam command line to prevent pam from performing special processing on the characters (such as <, >, #, space, |, ;, &, *, ?, [). A pair of double (") or single (') quote characters can be used to enclose the character string being quoted. The \ character quotes only the single following character. Scripts A script is an executable file containing command lines and comments. A comment is a line that begins with "!" or "#"; comments are ignored by pam. The command lines in the script file are executed in sequence (unless non- sequential execution is explicitely specified using the "&" character). Script arguments that are specified when a script is run can be accessed by script commands using the notation "$1" for the first argument, "$2" for the second argument, etc. All arguments can be accessed at once using "$*". The name of the script can be accessed using Hewlett-Packard Company - 4 - Aug 3, 1989 PAM(1) HP-UX PAM(1) "$0". Autost If a file named Autost exists in the open folder when pam is started, it is automatically processed as a command. If Autost is a script file, it is run as source Autost (see Built-In Commands described later). Otherwise, it is processed as if it were entered as a command (for example, if Autost is a data file, it is viewed). Pam does not process any command input until processing of the Autost file is complete. Environment The pam environment is set up when pam is run, and can be reset at any time by using the command getenv. The environment variables are read from a file and are not sorted or checked for syntax by pam. Pam passes the current environment to commands that it starts and uses the following environment variables in running commands: ACTION The ACTION variable specifies a command name (corresponding to an executable file), and is used whenever a data file is specified as a command. The ACTION command is run in this case and the data file is passed as the first argument. The default value for ACTION is "view". HOME The HOME variable specifies a folder and is used whenever the "cd" command is run without an argument. The HOME folder specifies the directory to change to in this case. The default value for HOME is "/". LANG The LANG variable specifies the language for which the system is localized. The default value for LANG is n-computer. PATH The PATH variable specifies a list of folders. When pam runs a command it looks for it in the folders in the PATH list. SCRSHELL The SCRSHELL variable specifies the shell to be used by pam in running scripts. If the specified name does not contain a "/" then pam searches for the shell using the PATH environment variable. If the SCRSHELL is undefined or the specified Hewlett-Packard Company - 5 - Aug 3, 1989 PAM(1) HP-UX PAM(1) shell does not exist, the script is processed by pam. Menu The pam menu displays the following softkey menu labels corresponding to the indicated function keys: [function key 1] open, view, or start (a program), or reread [f2] echo [f3] arrow (toggle key) [f4] move [f5] copy [f6] rename [f7] delete [f8] close The command associated with a menu item is run whenever the item is selected by pressing the corresponding function key. The highlighted file name in the folder area of the display is used as a parameter for the command. The menu item associated with f3 is used to toggle the semantics of the arrow keys and is available only in non-windowed systems. f3 is initially set to use the arrow keys for manipulating the position of the file highlight in the folder area. f3 alternately controls movement of the cursor on the command line. Built-In Commands Several commands are executed directly by pam: cd [name] Make the named folder (directory) the open folder (current directory). If no folder is specified, the HOME environment variable is used to determine which folder to open. close Closes the open folder and displays the parent folder. copy name1 [name2] copy name1 [name2 ...] folder_name Copy name1 to name2; if name2 exists and is not a folder, it is overwritten. If only name1 is specified, the copy is completed with Hewlett-Packard Company - 6 - Aug 3, 1989 PAM(1) HP-UX PAM(1) the command toname2. If the last parameter specified is a folder, all the specified files are copied into that folder. delete name1 [name2 ...] The named files and folders (if empty) are deleted. echo [arg ...] Arguments are written to standard output. The echo menu item (menu item 2 and/or function key 2) writes the full pathname of the highlighted file in the folder area of the display to the command line. getenv name The named file is read in and used as the active environment. makefolder name1 [name2 ...] Folders are created and given the specified name(s). move name1 [name2] move name1 [name2] folder_name Rename file or folder name1 to name2. If name2 exists and is a file, it is overwritten. If only name1 is specified, use the command to name2 to complete the move. If the last parameter is a folder, all the specified files are moved into that folder. rename name1 [name2] rename file_name1 [file_name2 ...] folder_name Same as move. reread Reread the open folder and update the display. The keystroke CONTROL-L also does a reread. source name [arg ...] Read command lines from the named script file and execute them. A shell is NOT forked to execute the commands. Parameter substitution for the arguments (arg ...) is handled the same way as during regular script execution. to [name] Complete a pending copy, move or rename. The file or folder name Hewlett-Packard Company - 7 - Aug 3, 1989 PAM(1) HP-UX PAM(1) identifies the destination for a preceding copy, move, or rename command that had no destination specified. If name is omitted, the destination defaults to the current open folder. view name1 [name2 ...] Copy the specified file(s) to standard output. If standard output is the screen (default), the file is displayed one page at a time. Signals Pam ignores INTERRUPT and QUIT signals if the command is followed by an "&"; otherwise pam uses default signal handling when running commands. Invoking Pam Pam can be invoked as a keyboard command or from a program. When pam is invoked without -c as the first argument, pam acts as an interactive, display-oriented command interpreter. When pam is invoked with -c as the first argument (either from the keyboard or from a running program), the remaining arguments in the command are interpreted as command inputs intended for processing by pam. The list of arguments intended as commands for pam must not exceed a total of 160 characters. When the -c option is used, pam executes the list of command arguments (built-in commands, redirection, pipes, and most other pam facilities can be used), then exits. Exiting from Pam To terminate pam and return to normal HP-UX operation, press CONTROL-D or CONTROL-C. NETWORKING FEATURES RFA The following command is executed directly by pam: netunam pathname [string] Initiate a network connection to the specified system (as indicated by pathname) using the specified login (as indicated by string). If string is omitted, the network connection to the Hewlett-Packard Company - 8 - Aug 3, 1989 PAM(1) HP-UX PAM(1) specified system, if currently active, is disconnected. DEPENDENCIES With a non-windowed pam running on certain terminals, the shifted right and left arrow keys cannot be used to move the cursor on the command line. The environment variable LANG is not set up by pam. AUTHOR Pam was developed by HP. FILES $HOME/.environ $HOME/Autost /usr/lib/nls/n-computer/pam.cat /dev/null Hewlett-Packard Company - 9 - Aug 3, 1989
jim@EXPO.LCS.MIT.EDU (Jim Fulton) (08/04/89)
I believe that it would be very simple to add a little functionality to xterm that would allow [passing a window id to xterm to use]. This has been on my list of things to do the MIT xterm for a while (various X10 xterm's had this for quite a while), but I'm still working out the effects of window size changes (e.g. whether or not you should be able to turn the scrollbar on or switch between 80 and 132 columns) and whether or not anything special would be needed for Tek mode. The code is pretty trivial, but some of the thinking isn't. I won't promise that it'll be in our next release (as usual :-), but we're sympathetic.... Jim