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

Hello fellow Monks,


since I cannot find help on this matter on stackoverflow(http://stackoverflow.com/questions/11671370/perl-not-executing-command-when-in-debugger-or-as-a-win32daemon) and I did find only one unanswered question on the web regarding this problem, I will now try my luck here.

I have a Perl program (CertNanny) that executes a binary (sscep). If I try to run it in my Eclipse debugger (EPIC), the binary reports a return code of "53" (after $? >> 8). However, if I do call another binary (e.g. "dir" or an absolute path to another binary) it works. And if I make another small perl script that only calls the sscep binary - this also works.

Furthermore sscep does not have a return code of "53". Here is what I call:

my $cmd = q("C:\path\to\sscep.exe") open FH, "$cmd |" or die "Couldn't execute $cmd: $!\n"; while(defined(my $line = <FH>)) { chomp($line); print "$line\n"; } close FH;

The whole program works perfectly if executed from the command line. But as soon as I launch the debugger or install it as a service (Win32::Daemon), it reports this weird error. The software itself does not get executed.

So my core question is: Why is it reporting the error "53", what could be the reason for this or what does it mean. Since my wisdom on Perl ends here, I come to you for help and advice.

Thank you in advance.

Regards, Florian

P.S.: If I missed any important detail, please also take a look at my SO question, as there are a lot (possibly superflous) details on this issue.

  • Comment on Executing command line script in Eclipse or as Win32::Daemon does not work
  • Download Code

Replies are listed 'Best First'.
Re: Executing command line script in Eclipse or as Win32::Daemon does not work
by BrowserUk (Patriarch) on Jul 27, 2012 at 16:05 UTC
    Why is it reporting the error "53", what could be the reason for this or what does it mean.

    The return code 53 a system error code. You can find out is text quite easily:

    C:\test>perl -E"say $^E = 53" The network path was not found
    The whole program works perfectly if executed from the command line. But as soon as I launch the debugger or install it as a service (Win32::Daemon), it reports this weird error.

    You'll have to wait for someone else to explain the Eclipse problem; but when install it as a service, it probably means it is running under a userid (probably LocalSystem), which does not have the privileges to access the network.

    See here for more.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      I have to programs that lie close to each other on %HOME% and I can call one (openssl.exe) but not the other (sscep.exe). The paths are nearly the same, without spaces or any special chars. Also, the program does not reside on a network path, though this machine is a virtual machine (Desktop on Demand). Calling the program does print a line as the first action, so at least that output must happen if it gets launched.

      A service receives the privileges for SYSTEM, a user above administrator. So it should not be a permission problem.

      Thanks for your efforts, but I suppose this is not the solution to the problem.

        Thanks for your efforts, but I suppose this is not the solution to the problem.

        Hm. Error 53 is "The network path was not found", so if it isn't the path to the executable; then it must be a path the executable is trying to access.

        And if it runs successfully from your logon, but not as a service, there are two possibilities:

        1. The service runtime userid doesn't have permission.
        2. It is attempting to access the network resource before connectivity has been established.

          For example: that might mean your service is attempting to do this just after start-up before the network stack is properly initialised.

          Or it might mean that your user profile establishes connections (NET USE etc.) that are not available when you are not logged on.

        How to debug it? Get ProcessExplorer; run the sscep.exe from the command line and use ProcExp to suspend it. Then use View->LowerPane->Handles to inspect what network path(s) it accesses. Work out how your userid gains access to those network resources.

        Bottom line: This is a sysAdmin problem not a perl problem.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Re: Executing command line script in Eclipse or as Win32::Daemon does not work
by bulk88 (Priest) on Jul 27, 2012 at 16:40 UTC
    You forgot a semicolon.

    Have you tried doing
    my $cmd = q("dir"); open FH, "$cmd |" or die "Couldn't execute $cmd: $!\n"; while(defined(my $line = <FH>)) { chomp($line); print "$line\n"; } close FH;
    in the debugger and as a service?

      Sorry I have slightly altered the code and forgot the write the semicolon, it was there in the original when called before.

      I had already run it in the debugger, but now I tried it as a service as well: In a debugger, it works. But now as a service even my small test script doesn't work.

      So to summarize: My program does not work in the debugger or as a service, but as a command line (everything with administrator privileges). My small test script does work from command line and in the debugger but not as a service. The error they report is always the same (53). It seems I now have two (possibly related) errors: One not allowing me to run the program as a service and one in my program which stops me from executing it anywhere but a command prompt. How do I go on from here?

        Rather than running sscep.exe, have you tried running a shell command like dir to prove you have a shell available in debugger or service? or tried running something like "perl -e" print 'hello world'" in debugger or service to prove you can run exes at all?

        Your app, sscep.exe, might be multithreaded, and has a watchdog thread on it console writing thread, if you run it in a debugger, and sscep notices console writes are taking too long (because perl isn't collecting the lines since its frozen in a debugger), sscep can abort with random errors. When running as a service, as BrowserUK said, permissions. I'm not sure what happens if a service tries to draw a GUI from its service/local system account. Also stop using double quotes for your paths in Perl. You run the risk (how much I'm not sure) of creating control characters with those escapes, which can lead to your error 53 bad path.