0

My batch file looks like:

perl program.pl
input.txt  

My perl program asks for input file via user input. But when I am running my batch file, it just starts a perl program but do not automatically give "input.txt" on the next line as user input.
How to get it done.

BioDeveloper
  • 618
  • 3
  • 8
  • 25
  • You could maybe consider changing your Perl program to see if it was started with an argument and use that, if specified, as the filename without asking the user. Then you could do 'perl program.pl input.txt' – Mark Setchell Apr 05 '14 at 11:04

2 Answers2

1
echo input.txt|perl program.pl

In your batch file, you have two commands. One to start the perl program and one to open the input.txt file. Each line one command.

If you want the batch file to send the string input.txt into the perl program, use the echo command to send the string to stdout, and pipe stdout into the stdin of the perl program.

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Tested with this one liner: `echo testing| perl -e "$_=<>;chomp;$_=reverse$_;print qq{$_\n}"` – Miller Apr 05 '14 at 19:01
1

"Execute" your Batch file this way:

cmd < theFile.bat

For further details, see this post.

Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108