dge888
dge888

Reputation: 125

Run batch script with a server path in perl

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?

Upvotes: 0

Views: 930

Answers (1)

ikegami
ikegami

Reputation: 385897

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 \.

Upvotes: 2

Related Questions