A
amaccormack
I'm trying to set up various XP machines (all with cygwin installed and
sshd running) on our network so that I can run a bunch of regression
tests networked across them. Now, I dont want to have to bother logging
in to each one by hand and adding networked drives that match my own
machine, so I though I could use UNC paths. Here's what I came up with:
sub uncpath {
my $orig_dir = shift;
$orig_dir = `cygpath -m $orig_dir`;
chomp $orig_dir;
if ($orig_dir =~ /^([A-Z])\:/i) {
my $drive = $1;
open GETUNC, "net use|";
NETUSE: while (<GETUNC>) {
if (/^OK\s+$drive\:\s+(\S+)/i) {
my $unc = $1;
$unc =~ s|\\|/|g;
$orig_dir =~ s|$drive\:|$unc|i;
last NETUSE;
}
}
}
return $orig_dir;
}
Maybe there's a better way, but this does seem to work. However, when I
ssh to another machine, it cannot find the UNC path until there is at
least one drive mapped to the server... e.g.
me@mybox ~ ls //serv1/x/y/z
....runs OK...
me@anotherbox ~ ls //serv1/x/y/z
ls: reading directory //serv1: bad file descriptor
me@anotherbox ~ net use z: \\\\serv1\\some\\other\\path
me@anotherbox ~ ls //serv1/x/y/z
....now runs OK...
So, I wondered if there was an easy way to force the other machine to
know abour serv1? I can always put a net use command in my startup
script, but that seems too hacky (although the hackiness is already way
more than I'd like)
sshd running) on our network so that I can run a bunch of regression
tests networked across them. Now, I dont want to have to bother logging
in to each one by hand and adding networked drives that match my own
machine, so I though I could use UNC paths. Here's what I came up with:
sub uncpath {
my $orig_dir = shift;
$orig_dir = `cygpath -m $orig_dir`;
chomp $orig_dir;
if ($orig_dir =~ /^([A-Z])\:/i) {
my $drive = $1;
open GETUNC, "net use|";
NETUSE: while (<GETUNC>) {
if (/^OK\s+$drive\:\s+(\S+)/i) {
my $unc = $1;
$unc =~ s|\\|/|g;
$orig_dir =~ s|$drive\:|$unc|i;
last NETUSE;
}
}
}
return $orig_dir;
}
Maybe there's a better way, but this does seem to work. However, when I
ssh to another machine, it cannot find the UNC path until there is at
least one drive mapped to the server... e.g.
me@mybox ~ ls //serv1/x/y/z
....runs OK...
me@anotherbox ~ ls //serv1/x/y/z
ls: reading directory //serv1: bad file descriptor
me@anotherbox ~ net use z: \\\\serv1\\some\\other\\path
me@anotherbox ~ ls //serv1/x/y/z
....now runs OK...
So, I wondered if there was an easy way to force the other machine to
know abour serv1? I can always put a net use command in my startup
script, but that seems too hacky (although the hackiness is already way
more than I'd like)