Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2015
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why have my system commands stopped working(windows)

    I have scripts that run the system() procedure for years, calling a system command with parameters, like thus:

    system("dir /AD /B");

    This used to work fine, but recently I noticed my scripts failing, it looks like the system command is not longer handling system command parameters the same.

    I get this error on the above command:
    dir: cannot access '/AD': No such file or directory
    dir: cannot access '/B': No such file or directory

    It's not taking in the options, its trying to run the command on them. I noticed the same issue with other windows commands like rmdir.

    I have been running this code for years, but we have updated our windows servers with security patches that must have changed something.

    Anyone else see this and know a solution for getting the system() routine to work correctly?

    Thanks a bunch
    hi

  2. #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    3,348
    Thanks
    2
    Thanked 233 Times in 226 Posts
    You can use the indirect object syntax.
    Code:
    system {'dir'} '/AD /B';
    This is explained in the documentation.
    perldoc -f system which points you to perldoc -f exec for additional details and is where the indirect object example is given.

  3. #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    3,348
    Thanks
    2
    Thanked 233 Times in 226 Posts
    I think (or at least hope) you know that making system calls like this when perl already has built-in (cross platform) methods for doing the exact same thing is a poor decision.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •