0

I have a exe file named file.exe When it is run through command line, it takes some data and process it and creates an output file.
I want to feed data to file.exe within a perl script and want the output file.

Please let me know the commands to do it. I am using windows operating system. I was reading about pipes, but unable to find the solution.

Edited by PhoenixInsilico

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by chandrashekar
0

Hi PhoenixInsilico,
Using perl inbuilt function system(...), you could do want you want. But really i don't know how you are feeding in your data into the executable file.
Below is an example. A simple C file to get a number from CLI. The file is complied as file.exe, and the Perl program that runs it is called file_exe.pl.

C Program file --- file.c

 #include <stdio.h>

int main(void){

    int number;

    printf("Enter your Value: ");
    scanf("%d",&number);  
    printf("%d\n",number);
    return 0;
}

Perl Program --- file_exe.pl

#!/usr/bin/perl -w
use strict;

my $exe_file = 'file.exe';

system( $exe_file );

Now running your Perl script, it just be as if you are using your normal CLI. You need not border about the output since your executable file has taken care of that.
Use as a guide. I hope it helps.

0

If you want to capture the output of the command/another program, use

$output=`COMMAND_TO_BE_EXECUTED`;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.