You haven't specified how kshell expects the returned data, so it's hard to help. Does it expect it via some IPC, or will it simply read from STDOUT? I expect that you could simply do command substitution via your perl script (using backticks) and have kshell read in the script's STDOUT results.