[ Previous ] [ Next ] [ Index ] [ C-Kermit Home ] [ Kermit Home ]
Article: of comp.protocols.kermit.misc
From: dallasii@surfree.com (Dallas E. Legan)
Subject: Case Study #20: Lynx/Kermit Coordination Part I
Date: Tue, 23 Jan 2001 05:59:14 -0800
Lynx/Kermit Coordination Part I
The version of ckermit2.txt that I currently have, (http://www.columbia.edu/kermit/ckermit2.html#x1.3.2) in the Lynx section on invoking C-Kermit from your browser (1.3.2) it states that 'As far as we know, this can be done only at compile time.' If you consider what happens when you hit return to be 'invoking', stictly speaking this is true. If your version of Lynx is compiled with general External support, however, in your /etc/lynx.cfg file there should be some lines like:
#***Must be compiled with USE_EXTERNALS to enable EXTERN *** KEYMAP:.:EXTERN # Run external program with url # or possibly: KEYMAP:,:EXTERN # run EXTERNAL with URL. added by d.e.l.
Make sure one of these is uncommented (no preceeding "#"), or add the lines if necessary. These should be located in a general set of Keymaps, with a lot of other similar statements. The defaults may be commented out.
Later in the file there will be a section called EXTERNAL. (Note that it is 'EXTERN' in the Keymap section, but the commands are assigned in the 'EXTERNAL' section.)
There you should have some lines:
USE_EXTERNALS:TRUE EXTERNAL:ftp:FTP %s &:TRUE # Where FTP is created by: # ln -s kermit FTP # when kermit is C-Kermit 7.1+ EXTERNAL:http:wget -P ~/download -q %s &:TRUE # This could even be another browser for HTTPs, instead of wget EXTERNAL:telnet:kermit -J %s:TRUE EXTERNAL:iksd:kermit %s:1649 :TRUE # (or) EXTERNAL:iksd:IKSget %s & :TRUE
The only ones needed for running kermit are the 'USE_EXTERNALS:TRUE' and the lines with kermit, iksd or FTP in them. The other, I include simply to show a typical other external program that could be defined. Again, make sure that there is no preceeding '#' on the line that would comment it out and render the line inoperative.
Now, when you hit return at a focused link, the default behavior of Lynx will result as typical - for instance if a 'telnet://aztec2.asu.edu' link the conventional and less capable telnet program will be invoked. If however, you hit "." (or whatever you chose in the Keymap statement), C-Kermit will be invoked instead. (Similarly, over an http link, "." will in the case shown above invoke the wget program on an http URL.) Rather than a binary executable, the program specified by the EXTERNAL statement can be a shebang script (#!/path/interpreter on line 1), that could present a menu of options on how to handle the URL it is passed. This is possible because of how UNIX invokes external programs giving shebang scripts pretty much equality with binary executables. (Another possibility might be Frank da Cruz's 'IKSget' script.) My personal experience is that the program specification seemed sensitive to trailing spaces, so a little bit of experimentation may be needed [C-Kermit 8.0 handles IKSD URLs on the command line without script assistance. - Ed.] EXTERNALs can be used to enable Lynx to cope with URL schema it has no compiled in basis to deal with. For this reason I speculativly put the "IKSD://" (Internet Kermit Server Daemon) example above.
In keeping with the topic of Lynx/Kermit coordination then, I include the below Kerbang script that attempts to handle (or leave space for in the future) these variations of protocols to be called externally from Lynx. It's probably overkill, and some parts haven't been thoroughly tested yet (others have), but it should handle my needs for a while. It allows you to switch to an alternate WWW browser in mid-surfing session for interactive sessions, gives some options for IKSD and ftp if a file or path is specified, or hops to C-Kermit if appropriate. Keep in mind that this is a work in progress, but is what I currently use.
#!/usr/local/bin/kermit + # lynxbooster.ksc # # script for external programs for Lynx web browser # ( by D. E. Legan, 23 Jan. 2001 ) # Requires: Lynx, C-Kermit 7.1, 'FTP' link to kermit # and whatever suplemental # http user agents/browsers desired. # According to the Lynx documentation, it can handle # an URL of form: # telnet://user:password@host:port # and also can handle rlogin, tn3270, tn5250 protocols similarly # Reading over the Lynx documentation for ftp URLs # it can handle a form of: # ftp://user@host:port/path;type=[D,I,or A] # (D,I,A = directory, binary or ASCII) # where user might be broken down to actually be # a user:password. if this followed average ftp # conventions, then it might actually be: # ftp://username:user@homehost@remotehost:port/path;type=[D,I,orA] # Personally, I've never seen the ';type=...' part of the URL, # so for the time being, I will ignore it, but will allot for # some of the other complications. # For using C-Kermit 7.1 ftp personality, # a soft link named 'FTP' has been made to the executable, # to distinguish it from the plain vanilla conventional # ftp executable. # USAGE: # In the lynx configuration file (typicly, lynx.cfg # or lynx-ssl.cfg) there should be some lines # like the following (not commented with '#' in column 1 # though :-) ) to activate this program: # #KEYMAP:,:EXTERN # run EXTERNAL with URL. added by d.e.l. #........... #USE_EXTERNALS:TRUE #........... #EXTERNAL:ftp:lynxbooster.ksc %s:TRUE #EXTERNAL:http:lynxbooster.ksc %s:TRUE #EXTERNAL:telnet:lynxbooster.ksc %s:TRUE #EXTERNAL:rlogin:lynxbooster.ksc %s:TRUE #EXTERNAL:tn3270:lynxbooster.ksc %s:TRUE #EXTERNAL:tn5250:lynxbooster.ksc %s:TRUE #EXTERNAL:iksd:lynxbooster.ksc %s:TRUE # If not already defined, the KEYMAP value (in this case ',') # should be chosen so as not to conflict with other Lynx control # keys. # (You can have more than one character KEYMAPped to EXTERN.) # When over a link to one of these protocols, hit this key # instead of return to activate this script for the link. # The EXTERNAL statements define the protocols that external # commands will be available for (in this case, # ftp, http, telnet, rlogin, tn3270 tn5250 and iksd), and the # program to be run for them (in this case this script.) # Note that if any external programs are called for # 'telnetish' protocols via pty/pipe/exec, # they may require adjustments of this script. # I don't have any of the IBM protocols on the system this # script has been developed on. # Variables: # \%a - address of URL # \%b - user input selection flag # \%d - raw URL # \%f - file name stripped of directory # \%i - path/file # \%p - port number # \%q - path # \%r - protocol this script is being used for # \%t - index used in parsing the URL as specified above # \%u - user ID # \%w - password echo {LYNX_VERSION = \$(LYNX_VERSION)} # According to Lynx man pages, this variable is always set by Lynx set case off # First let's pick apart the URL for possibly usefull parts .\%d := \%1 .\%a := \%d .\%r := \%a # strip the protocol from the URL: .\%a := \Flop(\%a,:) ; strip off up to '://' .\%a := \Fltrim(\%a,/) # extract the protocol, up to '://': .\%r := \Freplace(\%r,://\%a,) # First, we set up any URL protocol specific items: # (this section is largely an artifact of development process # but left in for future complications.) switch \%r { :telnet, :rlogin, :ftp, :http, :iksd, # this version, not much really needed here yet. :-) .\%c := kermit break # I haven't actually seen any mention of the # next five URL types yet, but what the heck..... :ssh, :telnet-ssl, :s5telnet, :ktelnet, :srp-telnet, # Back to reality: :tn3270, :tn5250, :default, # included for future generalization of this script echo \%r protocol currently not supported. ask \%z Press enter to continue quit .\%c = {pty \%r } .\%s := { } break } # Finished handling URL protocol specific stuff # Check to see if a directory/filename is on the end of the URL # indicates that this is a particular file to be downloaded from an IKSD: .\%i := /\Flop(\%a,/) # i holds the path/filename .\%a := \Freplace(\%a,\%i) # a holds usrid:password@host.domain:port # extract filename: .\%f := \Freplace(\%i,\Fstripx(\%i,/),) # f has the directory removed .\%f := \Fltrim(\%f,/) # now f has any '/' trimmed off .\%q := \Freplace(\%i,\%f,) # q holds just the path name # Now handle 'User:password' part of URL: # find the '@'s location in the URL: .\%t := \Findex(@,\%a) # Definitly set defaults for user and password: .\%u := { } set login userid .\%w := { } if > \%t 0 { # extract and clean up the 'usrid:password': .\%u := \Fstripx(\%a,@) # extract and clean up the 'host.domain:port': .\%a := \Flop(\%a,@) .\%a := \Flop(\%a,@) # the ftp two '@' case # is there a password? .\%t := \Findex(:,\%u) # Now seperate the user id from the password if present: if > \%t 0 { .\%w := \Flop(\%u,:) .\%u := \Fright(\%u,\%t) .\%u := \Ftrim(\%u,:) } # For kermit: set ftp autologin on set ftp user \%u \%w set login userid \%u } # Finished extracting user/password # Now handle any port part of the URL: .\%p := { } # Is there a port specified? .\%t := \Findex(:,\%a) # 'host.domain:port' are divided at \%t index # Now, if a port was specified: if > \%t 0 { .\%p := \Flop(\%a,:) .\%a := \Freplace(\%a,\%p,) if equal \%p kermit .\%p := 1649 .\%a := \Ftrim(\%a,:) if equal \%r telnet if equal \%p 1649 - if not equal {\%i} {} { # this case is really not interactive, but in fact IKSD # to a specific file .\%r := IKSD } } # End of handling port number # Handle HTTP/interactive selections here: # Make this script do double duty, by putting the following line # in the printer setup part of the your Lynx configuration file. # Then you can pass the URL of the currently viewed page # (not just the currently active link) to other browsers: # PRINTER:View URL with other browser:exec /path/lynxbooster.ksc ${LYNX_PRINT_URL}:TRUE # (hit the 'p' key, and select 'View URL with other browser' to bring # up this menu.) # See the Lynx man pages for information on enviromental variable # LYNX_PRINT_URL. if equal \%r http { # This part should be adjusted for whatever suplemental # HTTP tools you want to use. if equal {\%f} {} .\%f := \%a clear screen # -- try to keep this screen formating/menu simple and uncluttered :wwwchoice echo echo To connect to \%a\, choose an alternate browser: echo # most of these are frame-capable browsers # (Lynx barely handles frames.): echo { N Netscape} echo { W w3m} echo { L Links} echo { D Debris} # Warning about Debris: I'm certain it will be great when complete, # but it is a work in progress. My experience is that if you notice # this script flashing on the screen and canceling before you can do # anything, you may of called Debris once too often :-) # and a few methods of dumping files/directories # in background: echo { Y Lynx/dump in background} echo { R Wget/recurse in background} echo { X Exit back to Lynx} # echo { E Etc.........} # Could have Lynx using some drasticly different configuration # file listed in here, maybe special provisions for handling cookies. echo ask \%b {Alternate browser choice: } echo \%b switch \%b { :N, exec netscape \%d break :W, exec w3m -M -F -no-cookie -no-mouse \%d break :L, exec links \%d break :D, exec debris \%d break :Y, run lynx -source \%d > \%f & # May want to put cookie handling capabilities # with the above command # or maybe nohup this to direct the output # away from the screen break :R, run wget -D \%a -P \v(download) -np -brkl5 \%d break # -D \%a - restricted to \%a domain # -P \v(download) - put in download directory # -np - no parent directories # -b - go to background # -r - download recursively # -k - 'konvert' to relative links # -l5 - limit to just 5 levels of recursion :X, break # exit back to Lynx :default, echo {Invalid choice, try again}, goto wwwchoice } quit } # end of HTTP/interactive selection if not equal {\%p} { } .\%p := :\%p else .\%p := # If a specific directory/file is defined to retreive, hop to # non-interactive options # if not equal {\%i} {} forward getafile # temp (X) : set ftp autologin on if not equal {\%f} {} forward getafile # No file is specified # Assumption is that they expect you to browse # directory for whatever reason. if equal \%r ftp { if not equal {\%w} { } exec FTP -u \%u -P \%w -S -D \%q \%a \%p if not equal {\%u} { } exec FTP -u \%u -S -D \%q \%a \%p exec FTP -A -S -D \%q \%a \%p } if equal \%r iksd { if equal {\%w} { } .\%w := \v(userid)@\v(host) if equal {\%u} { } .\%u := anonymous # It seems to work best for me if normal initialization # is carried out before making an IKSD connection take ~/.kermrc set network type tcp set host telnet://\%a\%p remote login \%u \%w remote cd \%i end } # Parts from here to ':modechoice' will probably need modification # if any protocols that actually use pty/pipe external # programs are used. # So if a password was given: if not equal {\%w} { } { echo { Remember, in the URL} echo { the fools gave you this password: \%w} ask \%z Press any key to continue } # If a userid was given: if not equal {\%u} { } { exec kermit -M \%u \%r://\%a\%p\%i forward the_end } # If no userid was part of the URL: exec kermit -J \%r://\%a\%p\%i forward the_end # Here handle getting a specific file: :getafile clear screen # -- try to keep this screen formating/menu simple and uncluttered :modechoice echo echo To connect to \%a and retreive \%i, echo using \%r protocol, choose a mode: echo echo { F Foreground - 'I like to watch'} echo { B Background - 'My time is precious'} echo { X Exit - 'I need to do something else'} echo echo d is \%d echo r is \%r ask \%b {Job mode choice: } echo \%b switch \%b { :f, if equal \%r ftp { exec FTP \%d # Using C-Kermit 7.1 FTP personality break } exec kermit \%d # Use IKSget if using older version, pre-7.1 # instead of kermit here. # May want to nohup this to control output break :b, if equal \%r ftp { run FTP \%d & # Again, Using C-Kermit 7.1's FTP personality # May want to nohup this to control output # otherwise may need to ^L to refresh screen as # messages arrive from the background break } run kermit \%d & # Again, use IKSget if using older version, pre-7.1 # instead of kermit here. # ditto the above ftp comments break :x, break :default, echo {Invalid choice, try again}, goto modechoice } forward the_end :the_end echo Exiting lynxbooster.ksc quit
Thanks to everyone at the Kermit center for the help they've provided many times.
- Dallas E. Legan
[ Top ] [ Previous ] [ Next ] [ Index ] [ C-Kermit Home ] [ Kermit Home ]
C-Kermit 7.1 / Columbia University / kermit@columbia.edu / 29 Jan 2001