0

I have a perl script that goes out and executes a handful of batch scripts. I am only using these batch scripts because batch can parse through a directory of 1000s of files a lot faster than perl, or at least I can't find an fast way in perl to do it. Right now the code is local, so I was using a directory path based on how I mapped my drives to start the scripts, like this:

system("start J:/scoreboard/scripts/Actual/update_current_build.bat "."\"$rows[0][$count]\" "."\"*\" "."\"$output_file\"");

I need to make it more portable so that it can run from any machine. I tried using the server path, but when the batch script executes it says that I have an 'Invalid switch - "/".

system("start //server/share/scoreboard/scripts/Actual/update_current_standards.bat "."\"$output_file\"");

So my ultimate question is, how do I start a batch script using the server path?

1
  • It's called a "UNC path" Commented Feb 3, 2014 at 16:52

1 Answer 1

2

While Windows itself accepts / and \ as a directory separator, not every program does.

>dir c:\
 Volume in drive C is OS
...

>dir c:/
Invalid switch - "".

The problem is that / marks the start of an option (e.g. dir /s/b).

You could simply use the other slash.

system(qq{start \\\\server\\... "$output_file"}); 

For many of these programs, quotes disambiguate.

>dir "c:/"
 Volume in drive C is OS
...

So we just the need to execute start "//..."? No. start has a weird syntax. If the first argument is quoted, it's treated as the title to use for the console.

start cmd        # Ok
start "cmd"      # XXX
start "" "cmd"   # Ok

So you will need something like the following:

system(qq{start "" "//..." "$output_file"}); 

Unfortunately, it doesn't seem to work. This isn't a case where quotes help. It really does want \.

Sign up to request clarification or add additional context in comments.

4 Comments

Ok your explanation and everything makes sense, but is saying that "The sytem cannot find the path specified" and that it "Cannot find the file \\..\..\update_current_standards.bat"
I got rid of the "Cannot find file" error because I had the path wrong, but I am still getting "The system cannot find the path specified" error. The path now looks like: system(qq{"start \\\\server\\share\\scoreboard\\scripts\\Actual\\update_current_build.bat "."\"$rows[0][$count]\" "."\"*\" "."\"$output_file\""});
Alright NOW it is working. I didn't realize that you didn't have the quotes before start and around the path. Thanks!!!
I used qq{..."...} instead of "...\"...". They mean the same thing, but the former is just a tad cleaner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.