Good catch Corion.
So what you want to do is open a shell with your tool setup script and in that shell enter your the second command.
Something like the following might do it for you
#! /usr/bin/perl
use strict;
my $tool_shell = '/bin/toolsetup.pl -p coi -config d4 -t all -ov /nfs/
+home/akmvx/test -n toptest';
open (my $ts , "|-" , $tool_shell)
|| die "Failed to open tool setup:\n\tCommand:\t$tool_shell\n\tErro
+r:\t$!\n";
print $ts "touch file1\n";
print $ts "$exit_command";
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
|