#! /bin/sh
perl prog1 -x ./env.sh foo bar
[ -f ./env.sh ] && ./env.sh
perl prog2 quux
The idea is that prog1 writes valid shell commands to the env.sh file, does whatever else it has to do and then exits. Execution flow returns to the outer shell, which then sources the file that it wrote.
The prog2 program then runs, and picks up what ever environment changes were made by env.sh.
This is rather fragile and insecure. If you are brave and insist on this approach you really should consider using IPC (Inter-Process Communication) for a more robust solution. The idea is to create a channel of communication (child writes, parent reads) between the two. See perlipc for more information.
• another intruder with the mooring in the heart of the Perl
|