want perl demo .cshrc,.login 
Author Message
 want perl demo .cshrc,.login

does writing .cshrc and .login files in perl make sense?
operating on many platforms i've found that my decision
branches in my csh .cshrc file are becoming unwieldy, and
i would like to switch to a perl .cshrc file, but i'm not
sure how to equivalence such c-shell internals as "set"
and "setenv". if you have a (working) example .cshrc/.login which
performs the normal .cshrc functions (set prompt, setenv, stty)
i'd really like to see it. please e-mail your responses,
and if i get something of general interest i'll post it.
thanks,
charlie

--
Charlie Zender                Tel: (303) 497-1612
NCAR/CGD/CMS Rm ML-320        fax: (303) 497-1324

Boulder CO 80307-3000         http://www.*-*-*.com/



Fri, 14 Mar 1997 05:29:21 GMT  
 want perl demo .cshrc,.login

Quote:

> does writing .cshrc and .login files in perl make sense?

Well ... since Perl would be running as a child to your login shell,
it is unable to set the parent shell's environment directly (this is
due to the structure of Unix, not perl itself ... children cannot
directly alter parents' environments).  This means that 'setenv' stuff
couldn't be directly done.  Since 'set' variables and aliases are
local to the current invocation of your C shell, the same holds true
with these.

However, you could make your .cshrc look something like this:

        eval `cshrc.pl`

... where 'cshrc.pl' is a perl script.  This script could look something
like this:

        #!/usr/local/bin/perl

        # Do various system initialization things here not involving
        # aliases, set's, or setenv's.

        # etc. ...

        # End of system initializations.

        # Handle aliases like this:

        $alias{'ls'} = '/bin/ls -FACs'
        $alias{'j'}  = 'jobs -l'
        # etc. ...

        # Handle set's like this:

        $set{'noclobber'} = '1';
        $set{'path'}      = '( . ~/bin /etc /usr/ucb /usr/bin /bin )';
        # etc. ...


        $ENV{'VISUAL'} = '/usr/local/bin/emacs';
        $ENV{'PAGER'}  = '/usr/local/bin/less';
        # Note the embedded double quotes in the next one ...
        $ENV{'ORGANIZAION'} = '"The name of my organization"';
        # etc. ...

        # Now, generate 'alias', 'set', and 'setenv' statements
        # and print them to stdout:

        while (($key, $value) = each %alias) {
                print "alias $key '$value'\n";
        }
        while (($key, $value) = each %set) {
                print "set $key = $value\n";
        }
        while (($key, $value) = each %ENV) {
                print "setenv $key $value\n";
        }

Since you are generating 'alias', 'set', and 'setenv' statements to
stdout and evaluating them in the C Shell via the 'eval' and backquote
constructs, they will all get properly evaluated in the context of
your shell.  Same holds true for a "login.pl" script for your .login.

--
Lloyd Zusman            01234567 <-- The world famous Indent-o-Meter.

   To get my PGP public key automatically mailed to you, please
   send me email with the following string as the subject:
                    mail-request public-key



Fri, 14 Mar 1997 06:07:52 GMT  
 want perl demo .cshrc,.login

Quote:

>does writing .cshrc and .login files in perl make sense?

No.

Quote:
>operating on many platforms i've found that my decision
>branches in my csh .cshrc file are becoming unwieldy, and
>i would like to switch to a perl .cshrc file, but i'm not
>sure how to equivalence such c-shell internals as "set"
>and "setenv".

You can't.  .cshrc is fed into your csh interpreter and will
accept no other syntax but csh.  You are allowed (kibo?) to
use perl in your .cshrc, but I don't think it's generally a
goo idea.

Anno



Fri, 14 Mar 1997 06:38:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Not sourcing .cshrc

2. CR before login or any help that would lf before login

3. Perl CGI components + demo

4. Perl 5.001 + Tk: broken demo, broken evaluation?

5. Simple but complete stand-alone demo perl object program (C++ too)

6. perl/tk demos/examples

7. Tk demos in the Perl Journal # 6

8. Help: Perl script to automate https secured login session

9. Perl security as login shell

10. Perl scripts for login control

11. oracle database login with perl DBD/DBI and kerberos authentication

12. perl as login shell

 

 
Powered by phpBB® Forum Software