print "User, are you sure you wait to wait\n";
print "Type Y for yes or N for no\n";
chomp ($input = <STDIN>);
if ($input eq N){&exit) else ($input eq Y){&run_command};
sub run_command {
system(command);
}
sub exit {
print "Sorry you are so impatient\n";
}
HTH - Stiddy. That should get you on the right track.
Do you want to give them a chance to opt out of executing the command (Stiddy's method) or run it in a separate thread and allow them to cancel execution half way through when they get fed up with waiting (obviously CTRL-C is a simple if rather inelegant option here).
Obviously I would want to start executing the process but allow the user to abort the thread if it takes too long, without aborting the parent process.
I figured out I can just spawn a command in the background with system("command &") and then allow them to abort by killing the PID within the script. Thanks.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.