MJ G
MJ G

Reputation: 1

From Perl running batch script, Script expects STDIN

In Windows, I want to run a batch script in perl. This batch script wants two inputs from the user, but I want these inputs to come from the perl script. I've tried doing an echo | batchscript but that only works for one input. Currently I'm implementing it like this:

chdir "C:\\folder\\folder\\folder";
`some batch script`;
`echo variable`;
`echo filename`;

Another way I tried:

chdir "C:\\folder\\folder\\folder";
`echo variable | some batch script`;
`echo filename`;

The variable and filename are the two inputs that the script prompts for before continuing. Neither works. Anything helps. Thanks

Upvotes: 0

Views: 143

Answers (1)

glenn jackman
glenn jackman

Reputation: 246744

As the script reads from stdin:

my $script_out = qx(printf "%s\n" variable filename | script.sh);

Upvotes: 1

Related Questions