http://qs321.pair.com?node_id=376816


in reply to How to send Ctrl^C to a program via Expect module

You should use the soft_close() or hard_close() methods. Please take a look at the documentation for the Expect module. Here's a simple example:

#!/usr/bin/perl use strict; use warnings; use Expect; my $command = "cat > tmp.txt"; my @params; my $exp = Expect->spawn($command, @params) or die "Cannot spawn $command: $!\n"; print("sending...\n"); $exp->send("Hello world\n"); sleep 1; $exp->hard_close; __END__

Or, if you really want to send Ctrl-C to your process, try this: $exp->send("\cC");. Or you can just send a signal to the process like Fletch recommends.