If I want to make a command interpretation shell,where and how to store the rule of those command.

If I want to make a command interpretation shell,where and how to store the rule of those command.

Post by coolbo » Tue, 24 Jul 2001 10:18:40



I want to make a command interpretation shell,like sch,where and how to
store the rule of those command.
How to organize those command structure!
Thanks!
 
 
 

1. Making perl a builtin command dtksh command on AIX 4.x

Ok, I'm trying to make perl5.004_04 be a builtin function in dtksh on AIX414.

[ No, no, please keep reading!  Especially AIX 4.x system gurus! ]

Mainly as an interesting experiment, but with a view toward speeding
up perl access.  I'm getting segfaults whenever dynamically loaded
modules like POSIX are use'd.  The segfault occurs in boot_POSIX.
And yes, I think I'm using the xs_init() function properly.  My
"by-the-book" substitute perlmain.c is appended below.

[ AIX users please try this at home. ]

After copying perl.exp from $Config{archlibexp}/CORE to $PWD,
I link myperl with

     cc -o myperl b_perl.c -bE:funcs_perl.exp \
        `perl -MExtUtils::Embed -e ccopts -e ldopts`

The funcs_perl.exp file contains the single line ``b_b_perl'', which
is use to tell dtksh that b_perl can be used as a builtin (the first
b_ is required by dtksh).

Now, the resulting myperl can be run at the command line and functions
just like perl, with ``use POSIX; print strftime "%D", localtime'' working
fine, ie., no problems with dynamic loading.

To make b_perl a dtksh builtin, you do this (under dtksh, of course)

        builtin -f myperl
        builtin b_perl

after that, stuff like ``b_perl -le 'print 1..99''' works fine,
but ``use POSIX'' segfaults in boot_POSIX, and ``use MD5'' segfaults
in boot_MD5.

Is there enything inherent in the way these extensions are constructed
that would prevent them from working when dynamically loaded from perl
if perl itself is dynamically loaded (which dtksh is doing when it
processes the ``builtin -f myperl''.  I'm not positive, but I think
dtksh is using the load() system call.)?

Any ideas much appreciated.

John.

----- b_perl.c -----
#include <EXTERN.h>     /* from the Perl distribution */
#include <perl.h>       /* from the Perl distribution */

static void xs_init _((void));

static PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/

int b_b_perl(int argc, char **argv, char **env)
{
  my_perl = perl_alloc();
  perl_construct(my_perl);
  perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
  perl_run(my_perl);
  perl_destruct(my_perl);
  perl_free(my_perl);

int main(int argc, char **argv, char **env)
{
b_b_perl(argc, argv, env);

extern void boot_DynaLoader _((CV* cv));

static void
xs_init()
{
    char *file = __FILE__;
    dXSUB_SYS;
        newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
-------------------
--

~\Allen/~Fax: 516-575-7428    <Universe>: 1e22 stars = 22 solar masses per sec

2. how to use array variable in AWK

3. Date stamping commands in the shell command history file

4. Problem with cachefs logs

5. problem with executing commands from within the shell using a command string.

6. Stereotypical Linuxite (was Re: Linux for rednecks? (Was xearth & new age music))

7. C shell command to use 'file' command to automatically scale a file

8. which hardware to record tv on linux ?

9. Shell for exceuting HTTP/SMTP commands at windows command line

10. diff among echo a>f; command<f; echo $a|command; command << $a; EOF

11. How can command matching with few letter from korn shell command line?

12. emacs shell-command-on-region command can't execute on Slackware.

13. Command completion for Korn Shell command line