VingInMedina has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to set up a program that will perform a set of user defined steps. Each step will be a seperate program, which could be anything (e.g. shell script, unix command, c++ program, perl program). My program will execute the specified command and check the return code. If the return code is 0, my program will move onto the next user defined step.

Here is my problem, any one of the specified steps could be a program that needs input from the user. What I want to do is have my program turn over control to the executed program (allowing the user to specify any necessary termial input) and return control back to me when it finishes. All I need from this is the return code of the executed process.

I've tried just using system() call, but that won't get STDIN from the user.

Any ideas?

Here is my program so far (

#!/usr/bin/perl $scriptName = ''; $logFileName = ''; $numberOfSteps = ''; $restart = 'Y'; @step = (); $error = 0; foreach $_ (@configFile) { next if ($_ =~ /^\s*$/); next if ($_ =~ /^\s*#/); chop(); if ($_ =~ /^\s*ScriptName:\s+\S+\s*$/) { ($tag,$scriptName) = split(); } elsif ($_ =~ /^\s*LogFileName:\s+\S+\s*$/) { ($tag,$logFileName) = split(); } elsif ($_ =~ /^\s*NumberOfSteps:\s+[0-9]+\s*$/) { ($tag,$numberOfSteps) = split(); } elsif ($_ =~ /\s*Restart:\s+\S+\s*$/) { ($tag,$restart) = split(); } elsif ($_ =~ /^\s*Step\s+[0-9]:/) { $stepNum = $_; $stepNum =~ s/^\s*Step\s+([0-9]+):.*$/$1/; $command = $_; $command =~ s/^\s*Step [0-9]:+\s+//; $step[$stepNum] = $command; } else { print STDERR "Error: unknown config file line:\n"; print STDERR " $_\n"; $error = 1; } } for ($i=1;$i<=$numberOfSteps;$i++) { print "$i: $step[$i]\n"; $ret = system($step[$i]); if ($ret) { print STDERR "\nError: last step failed.\n"; exit(1); } }

Here is a sample script to call this program

#!/bin/ksh << ! ScriptName: testScript LogFileName: boing NumberOfSteps: 4 Restart: N Step 2: ls -l Step 1: $HOME/bin/gettime Step 4: ps -elf | grep wam Step 3: /tmp/thing !

Here is the /tmp/thing script that asks for input

#!/bin/ksh print "This is the output." print "You need to enter a value: " read ans print "You entered the value of $ans." exit 1

When it runs the /tmp/thing script I am not given the chance to enter the requested input