Mar-21-2018, 06:14 AM
i'm starting to think through how to embed a Python script inside a shell script. the first issue that comes to mind is keep the data input and code input separate. i don't want to write the code to a separate file because it may be that there is no file system mounted R/W. everything could be R/O. if i could tell Python to read the code from a specific file descriptor, that might work.
this involves Python code too big to squeeze onto one line. it might be on the next 100 lines of the shell script. in Linux i could use something like /proc/self/fd/9 as the source code to run an input lines below via that descriptor, like 9<<EOF and put EOF after the last line of code. if this works, then i would have each piece of Python code be organized as a shell function so it can be used like a command in a long shell script pipeline. the idea is that i can get started converting just critical pieces of shell scripts to Python without have to wait until i have time to convert the whole thing to Python.
this involves Python code too big to squeeze onto one line. it might be on the next 100 lines of the shell script. in Linux i could use something like /proc/self/fd/9 as the source code to run an input lines below via that descriptor, like 9<<EOF and put EOF after the last line of code. if this works, then i would have each piece of Python code be organized as a shell function so it can be used like a command in a long shell script pipeline. the idea is that i can get started converting just critical pieces of shell scripts to Python without have to wait until i have time to convert the whole thing to Python.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.