Posts: 4,653
Threads: 1,496
Joined: Sep 2016
is there a way to get the Python engine to exec some command or script via a pipe and read the python code from that pipe as the code it will interpret? i have seen programs that read something from a file accept a '|' as the first character of a file name and treat the remaining characters as a command string and run that command to produce the contents. i have a couple cases where i would sometimes like to invoke the python command that way.
i've been thinking of adding this capability to my zopen() function. but that is not something the python engine uses.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,653
Threads: 1,496
Joined: Sep 2016
Dec-24-2021, 08:40 PM
(This post was last modified: Dec-24-2021, 08:40 PM by Skaperen.)
that's not what i am looking for. i an looking for a way to support "|" at the start of a file name string and have it work as a command to execute. the command to execute is after the "|". the output of the command is the contents to be used by the program as if from a file. if the python engine supported this and foo.py outputted the python code to be run then you could do '
python "|python foo.py"
' to run that code. but it does not support that. i am looking for a way to accomplish this.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,653
Threads: 1,496
Joined: Sep 2016
i'm not following that. maybe i need to read it a few more times.
the command line that outputs the python code to be run cannot have that code hardcoded in its own code. i need to be able to build any command line including those that get code somewhere on the internet at an unexpected place.
i am thinking of a wrapper that runs commands and saves output as temporary files then runs the real python with those temporary file names replacing the pipe prefix command string arguments. then i could adapt this for other commands.
i think that would work so i am thinking of a scheme to have just one such script that can figure out what is to really be run based on what command it replaces, such as
/usr/local/bin/pythonxy will run
/usr/bin/pythonxy after it saves the temporary files. that way i don't need to code a new script for each case. i would just symlink
/usr/local/bin/pythonxy -> /usr/local/bin/usr.bin.wrapper and would figure out the path to the real executable.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,653
Threads: 1,496
Joined: Sep 2016
"on the internet" can include securely verified and trusted sources. then it's not "blindly". or the command could construct code based on info/data from various sources. it's up to whoever determines the command to do it right.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.