Python Forum
embedding Python script in shell scripts
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
embedding Python script in shell scripts
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
embedding Python script in shell scripts - by Skaperen - Mar-21-2018, 06:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  embedded Python scripts - is it worthwhile Skaperen 3 699 Feb-21-2024, 01:25 AM
Last Post: Skaperen
  images and pixels in typical Python scripts Skaperen 0 1,247 Oct-14-2021, 12:29 AM
Last Post: Skaperen
  embedding data in a script Skaperen 1 2,095 May-31-2021, 07:19 AM
Last Post: Gribouillis
  Creating Python scripts in Visual Studio Code Sanjish 4 2,618 Dec-22-2020, 12:32 PM
Last Post: snippsat
  embedding python Skaperen 0 1,466 Apr-22-2020, 03:19 AM
Last Post: Skaperen
  suid scripts in python? Skaperen 0 2,161 Sep-29-2019, 10:28 PM
Last Post: Skaperen
  Python Shell As Preferred Mode For Integrated Terminal In Visual Studio Code adt 4 4,066 Sep-07-2019, 06:00 PM
Last Post: adt
  Can copyright be applied python scripts? tim777 3 4,907 Sep-04-2019, 12:20 PM
Last Post: DeaD_EyE
  Finding Scripts for Python Johnny1998 1 2,217 Jul-31-2019, 08:07 PM
Last Post: Yoriz
  Notepad vs anaconda spyder or python shell ShadowAlpha 2 2,956 Jun-26-2019, 06:31 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020