PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|LinuxGazette|issue117.txt =

page 3 of 60




     If our gentle readers have more ideas, or someone would like to do an
     article on really getting the most out of your camera under Linux, it'd
     be just the kind of thing to make Linux just a little more fun :) 
            ____________________________________________________

Problems with tcsh scripting

   Mon Jun 27 01:39:00 2005
   Aengus Walton ([35]ventolin at gmail.com)
   Answered By Ben Okopnik

   I have a number of issues with tcsh (not my choice..) shell scripting I need
   help with. 

   Basically I'm writing a shell script that automates a long setup procedure.
   This top-level script is in bash, however the bulk of it is comprised of
   commands that are fed to a program which is, in essence, a tcsh shell. I've
   achieved this by using the << redirector. I need help on two points: 

     1) Is there any way of suspending input redirection, taking input from the
     keyboard, and then resuming input from the tcsh script?

     [Ben] There is, but it is Fraught With Large Problems. I'm not that
     familiar with TCSH, but I've just had to do that in Perl - essentially, I
     was writing a Perl version of 'more' and had to answer the question of
     'how do you take user input from STDIN when the stream being paged is
     STDIN?' It requires duplicating the STDIN filehandle... but before you
     start  even  trying  to do it, let me point you to "CSH Programming
     Considered Harmful" - Tom Christiansen's famous essay on Why You Shouldn't
     Do That. If it's not your choice, then tell the people whose choice it is
     that They Shouldn't Do That. The task is complex enough, and has enough
     touchy problems of its own, that introducing CSH into the equation is like
     the Roadrunner handing an anvil to the Coyote when he's already standing
     on shaky ground over a cliff.

     To give you some useful direction, however - the answer lies in using
     'stty'.

   2) There comes a point towards the end of the script when two shell scripts
   are run simultaneously. These shell scripts open up individual xterm windows
   to run inside. I'm wondering, is there anyway of having the tcsh script
   monitor stdout of one xterm, and upon the output of a certain piece of
   text, echoing a command into the stdin of the other xterm? 

     [Ben] Why not 'tee' the output of the script - one 'branch' into the xterm
     and the other into a pipemill (or whatever you want to run 'grep' in)?

   Any insight or knowledge on the matter would be very much appreciated. I
   hope I have provided sufficient details. 

     [Ben] You have - from my perspective, anyway.

     If the gentle readers have more to say, please let Aengus know, and cc The
     Answer Gang so we can comment on the results or see his answer in a later
     issue. Artciles on working with shells beyond bash are always welcome. --
     Heather
     _________________________________________________________________

                                GENERAL MAIL
     _________________________________________________________________

     * [36]Correction to WSGI article
     * [37]Debian kernels without devfs
     * [38]Re: [LG 116] mailbag #1
     * [39]TAG "playmidy plays silently" LG#116
            ____________________________________________________

Correction to WSGI article

   Fri Jul 8 14:51:26 2005
   [40]Sluggo ([41]mso at oz.net)

   There's  a  mistake  in  my  "WSGI  Explorations  in  Python" article.
   [42]http://linuxgazette.net/115/orr.html It says,
                              ...............

   But both sides of WSGI must be in the same process, for the simple reason
   that the spec requires an open file object in the dictionary, and you can't
   pickle a file object and transmit it to another process.

                                 ...............

   Actually,  the  spec requires a file-like object, so an emulation like
   StringIO is allowed. StringIO is pickleable:

>>> from StringIO import StringIO
>>> sio = StringIO("abc")
>>> p = pickle.dumps(sio)
>>> p
"(iStringIO\nStringIO\np0\n(dp1\nS'softspace'\np2\nI0\nsS'buflist'..."
>>> sio.read()
'abc'
>>> sio.read()
"                   # End of file.
>>> sio2 = pickle.loads(p)
>>> sio2.read()
'abc'

   cStringIO, however, is not pickleable.
=3=

1|2| < PREV = PAGE 3 = NEXT > |4|5|6|7|8|9|10|11|12.60

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0334918 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)