die "Can't fork: $!" unless defined $pid = open(KID, "-|"); if ($pid) { # parent while () { # do something } close KID; } else { exec 'myprog', 'arg1', 'arg2' or die "can't exec myprog: $!"; } #### Shell Script: #!/bin/ksh # print the arguments for checking # $1 is the directory # $2 is the executable echo $1 echo $2 # change dir to $1 cd $1 # execute $2 $2 echo "Exit" #### ... ... $dir = 'some path'; # untainted $exe = 'some executable'; # untainted ... ... exec 'unixscript.sh', $dir, $exe ... ...