• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Issuing a DOS command from within my Perl program

I am using Perl for Win32 Build 316 and seem to have the following problem. Whenever I use the following format to issue a shell command

print `dos command goes here`;

my PC seems to look on the floppy drive (i.e. the light comes on and the drive grinds). The shell command still works (i.e. it doesn't fail through not finding the file), but it is obviously quite annoying. At first I thought it might be some kind of pathing problem, but even when I have reset the path, it still happens.

Any suggestions ?


Matt Freake
  • 2
1 Solution
Is a:\ in your search path?

Type: 'set' from a dosbox and look for the path= line
How did you 'reset' the path ?  The backticks will create a dos environment to run in, and maybe this environment has the floppy drive in the path.  I was using 316 until a few days ago, and I cannot reproduce the problem with it on my PC.
A few things to try:
- check the real environment with: print `set`;
- try using system() instead of backticks.  Although I don't see what this could change, I did get some strange behaviour with running dos commands (mostly concerned with arguments passing)
- put an exe file on a floppy and use: print `this.exe`;    Does it really gets executed, indicating there must be a 'a:' in the PATH used by the environment.

paninaroAuthor Commented:
Curiouser and curiouser. If I use
    print `set`;
A: does not seem to be in the path anywhere (though in carrying out the command, it does of course check the A:drive). Also if I put an exe file on a floppy and use:
    print `this.exe`;
the A: drive whirrs, the light comes on, but the screen says "bad command or file name".

However by using system, rather than the backticks, there the A: drive remains completely silent and the light remains firmly off (and the relevant DOS command works correctly). I'm beginning to wonder if maybe this is some kind of hardware problem.

Anyway, the "system" solution if good enough for me. So, how do I allocate points for this ?
Since the 'system' works for you, I am posting this answer so you can allocate the points.
A small remark concerning the exe test:  you did put the exe under the name 'this.exe' on the floppy, I suppose ?  I did not state this clearly in my response, and you didn't either in your comment.
Maybe that the backticks are looking for 'a:\command.com', but I have no idea why it would look on the a: drive.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now