in reply to Re: did you mean python
in thread did you mean python

python.c:37:3: error: call to undeclared function 'execvpe'; ISO C99 and later do not support implicit function declarations -Wimplicit-function-declaration
                execvpe("/usr/bin/python", argv, env);
                ^
1 error generated.

Replies are listed 'Best First'.
Re^3: did you mean python
by bliako (Abbot) on Jan 28, 2026 at 12:39 UTC

    Yes, execvpe() is a GNU extension. Replace said function and its params with this: execv("/usr/bin/python", argv); or add #define _GNU_SOURCE at the beginning if your compiler supports GNU extensions, e.g. gcc and I think clang. For M$ alternatives, good luck.

    P.S. You also need to adjust the (real) python path "/usr/bin/python" with whatever you have. And make sure that the real python executable does not shadow your newly created one. The new one must have precedence. That depends on your PATH env var and OS specific rules.

    P.S.2 The side-effect of this change would be that your current environment is not passed to the (real) python executable. I am not sure what happens if your python script expects env vars. Perhaps it will read the system-wide ones and ignore those session/terminal-specific ones you may have set earlier.

      Thank you bliako! execv("/usr/bin/python3", argv) did the trick. Now I have a Perl interpreter that runs python, whoa:

      Made 3 files:

      python.pl: print join " ", "hello", "world\n" python.py: print("hello", "world", sep=" ") pythone.py: import os print(os.environ['hello'])
      Got 3 results:
      % python python.pl It parses as Perl so I am running it ... hello world % python python.py Can't modify constant item in scalar assignment at python.py line 1, n +ear "" ") " Execution of python.py aborted due to compilation errors. I guess it is &*^#$* pyton /sic/ ... hello world % export hello="hello world" % python pythone.py syntax error at pythone.py line 2, near "environ[" Execution of pythone.py aborted due to compilation errors. I guess it is &*^#$* pyton /sic/ ... hello world
      How do I silence the error message from perl?

        I have updated the code in my original post to output syntax errors and debug messages only if env var PERL_PYTHON_EXECUTOR_DEBUG is set (e.g. PERL_PYTHON_EXECUTOR_DEBUG=1 python my.pl)

        I hope this serves as a springboard to experimenting with Perl embedded in C (you can run oneliner regexes in your code for example). and, why not?, XS.

        Perl is great.

        bw, bliako

        p.s. there is github-linguist which detects the type of comp.language.

        > How do I silence the error message from perl?

        I just changed this line

        printf("It parses as Perl so I am running it ...\n");
        to this
        fprintf(stderr, "It parses as Perl so I am running it ...\n");
        so i can silence or redirect stderr with 2>&1- or 2>logfile