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

Hi

I am using ActiveState perl with the developers toolkit to create an NT service, The problem is I need to run the following DOS command,

my @cmd_response = `cmd /c sort < in.txt`;

this produces no output, but it seems that STDIN is not avaliable to the when running as an NT4 service

It works OK with Win2K.

Thanks.

Replies are listed 'Best First'.
Re: Perl As a NT4 Service
by tachyon (Chancellor) on Jan 05, 2004 at 10:50 UTC

    Why shell out for DOS sort when you have perl sort?

    open F, 'in.txt' or die $!; my @sorted_lines = sort <F>; close F;

    cheers

    tachyon

      Sorry the code was only a simple example of the problem. I need to redirect a command file for intogation of mqseries queues.

      ie "runmqsc < command.txt"

        I'm not sure if this will work, but try going to control panel->Services

        Highlight your service, and select Startup... and then enable "Allow service to interact with Desktop".


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        Hooray!

Re: Perl As a NT4 Service
by revdiablo (Prior) on Jan 05, 2004 at 22:49 UTC

    This is a completely random guess. I don't work with Perl on Windows very often, and have never used it as a service. But maybe (and remember that's a big maybe, i.e. a completely random chance) there is a problem with the shell redirection not working right? Perhaps the environment perl is running in as an NT4 service does not provide enough richness that  < in.txt works right. I wonder if using Open2 or Open3 would be any help. (Do these even work on Windows? Again, this post is full of completely random guesses. I figured some replies would be better than none, if only to give you some ideas of what you can try.)