Mukunda has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I've a sample c program in one windows sytem.

main() { int x,y; printf("Please enter 1st number : "): scanf("%d", &x); printf("Please enter 2nd number : "): scanf("%d", &y); printf("sum is %d", (x+y)); }

I want to write a perl program on second system that executes the c program on the 1st windows system. Whatever the "printf" i'm giving in c should be seen in my perl output, and whatever i give the input in perl should go to c program as input. We have tried many ways but didn't succeed. Please help .

Replies are listed 'Best First'.
Re: Executing remote c program
by Anonymous Monk on Nov 25, 2011 at 08:44 UTC

    We have tried many ways but didn't succeed.

    What did you try?

Re: Executing remote c program
by zentara (Cardinal) on Nov 25, 2011 at 15:31 UTC
Re: Executing remote c program
by TJPride (Pilgrim) on Nov 25, 2011 at 12:04 UTC
    You could theoretically give the second system SSH access to the first system - this would allow it to run things from the command line. You'd need to install an SSH server on the first system, and set up a script with Net::SSH on the second system.
    http://search.cpan.org/~ivan/Net-SSH-0.09/SSH.pm
Re: Executing remote c program
by rovf (Priest) on Nov 25, 2011 at 09:51 UTC
    Note: This was crossposted at <http://perlguru.com/gforum.cgi?post=59729>.

    -- 
    Ronald Fischer <ynnor@mm.st>
Re: Executing remote c program
by McA (Priest) on Nov 25, 2011 at 11:16 UTC
    Hi,

    what I don't understand is, whether the c executable shall be started for every calculation or shall there be a kind of server on the remote site waiting for input for the calculation?

    What do you want to achieve?

    Best regards
    McA

Re: Executing remote c program
by locked_user sundialsvc4 (Abbot) on Nov 25, 2011 at 14:18 UTC

    Basically, what you need to use here is some kind of Remote Procedure Call (RPC) mechanism which is supported by both systems.   One computer must present a request to the other machine, in such a way that the other machine will consent to do it (and will know what to do and in whose name), and such that the results can easily and reliably be returned to the first machine.   Windows has lots of support for RPC mechanisms of Redmond’s own making, and you can certainly roll your own.   (Searching for RPC on http://search.cpan.org yielded 412 hits ... a great place to start.   This is not a wheel that you will have to re-invent.   Therefore plan to “pick and choose,” not “write,” this piece.)