Sam Levin
Sam Levin

Reputation: 3416

Run program (and respond to prompts) in background with perl?

How can I run a program on the command line and pass it input (after it runs) using perl? The goal is to run it on a cron script and design it so that it can't interrupt the user

For example, I'm looking to do this:

<run command>
Input required (program prompt): <injected by perl>
<end>

Upvotes: 1

Views: 353

Answers (2)

javamonk
javamonk

Reputation: 180

Using pipe?

perl xxx.pl | command

Upvotes: 0

Ben Grimm
Ben Grimm

Reputation: 4371

Expect will handle all of the tough parts for you. You'll have cron execute your perl program and it in turn will spawn the program requiring interaction. Then it's just a matter of coding the appropriate responses to the output the other program produces.

Upvotes: 2

Related Questions