Andrea Snadden wrote:
>
> Hi,
>
> I have a set of perl scripts that I use (on my Win2000 machine) to automate
> my software testing environment -- basically they do a lot of chdir'ing
> and
> system("start /b myprogram.exe")
>
> I really want to be able to use the same set of scripts on a Unix machine,
> but have run across the problem that, unlike Windows NT, Windows 2000
> doesn't cope at all with Unix-style forward slashes (eg. can't do a cd
> d:/myprograms/mysubdir you have to do a cd d:\myprograms\mysubdir)
Not true. The chdir function works fine with /s.
> Does any one know of a way to deal with this? Even a way to find out what
> OS the script thinks it's running in, so I could then have a switch to say
> which style of slashes to use?
$^O contains the OS name.
> A further question: is there a better way of starting myprogram.exe without
> relying on the system("start /b myprogram") command? My main reason for
> doing it this way is that I do not want a new window started every time I
> launch myprogram (I launch about 12 programs ... would end up with a lot
> extraneous windows), and I need to be able to return to the script (so exec
> wouldn't work).
Forward slashes work ok except on ``, system and pipes (at least on 9x, NT might
be even better). So use forward slashes whenever possible.
When not possible, just fix the slashes right before you need them.
eg: $path =~ s/\//\\/g if ($^O =~ /Win32/i);
If the system returns \s, you may want to immediately convert them back
to /s to maintain your script portability.
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.wgn.net/~dbe/
/ ) /--< o // // Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]