Not exactly a polyglot script, but a while back I had to work on a cluster whose job management system always ran everything as shell scripts. Or rather, it had to be run as a shell script in order to set the right cluster options. I wanted to submit an R script, so what did I do? I wrote a file that was both a bash script and an R script. When run as an R script, it does what I want it to do. When run as a bash script, it runs itself as an R script (after setting the cluster options). Problem "solved".
They may have only been able to submit the single file to the system. (In which case I would have generated the Rscript to a tmpfile, but maybe that wasn't allowed either.)
No, I totally could have written a separate R script that was then run by the bash script. I just wanted to have it all in one file, and I thought it was a fun challenge figuring out how to do it.
I think the difference with mine is that I actually need to squeeze some shell code in there as well, to set up the cluster environment before "handing off" to R/Python.
On a similar topic, PoC||GTFO [0] features files that are valid with multiple file formats. Issue 19 [1], for instance, "is valid as a PDF document, a ZIP archive, and a HTMLpage. It is also available as a Windows PE executable, a PNG image and an MP4 video" (see "technical note").
They are made by Ange Albertini [2] who has a great talk [3] on how he does this kind of things
What I would like to see is a way to use multiple languages within the same script, to use the different abilities of different languages. For eg: Query a database via Ruby using ActiveRecord, then do some number crunching in Python using numPy or Pandas, and finally plot some statistical charts using R.
Jupyter's multiple language kernels come close to this, but not quite.
Here is is, if anyone's interested: https://gist.github.com/DarwinAwardWinner/2eb3705fb6ddab08ee...
And here's the Python version: https://gist.github.com/DarwinAwardWinner/8a631d897d45f00552...