A
alt.testing
Hi all,
the simple concept of escaping a "backslash", thus translating to a
literal backslash; does not provide the implied result, under the
following example.
$mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
/mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
password=$pass#;
The top part of the "strace" output gives this:
execve("/bin/mount", ["/bin/mount", "-t", "smbfs", "\\an2documents",
"/mnt/workstation_shares/xxxx/doc"..., "-o", "ro", "-o",
"username=xxxx", "-o", "password=xxxxxxxxxx"], [/* 22 vars */]) = 0
"\\an2documents"
Note; that there is no "\" in between the machine name, and the share.
It should be "\\an2\documents".
[root@mercedes sbin]# perl -e 'print "\\\\an2\\documents\n"'
\\an2\documents
I'm sure it's a simple thing, but can someone enlighten me on this
parlay?
ta.
Full Context
===============================================================================
#!/usr/bin/perl
use strict;
use warnings;
my $input_vars_file = "/usr/local/etc/priv/users_test";
my $tmp_vars;
my $input_vars;
my @input_vars_array;
my @target_vars_array;
my $user;
my $pass;
my $machine;
my $mount;
my $mount_result;
open ( IN_FILE, "< $input_vars_file") or die "$!";
while ( <IN_FILE> ){
$tmp_vars = $_;
$tmp_vars =~ s/(\s+)/,/g;
$tmp_vars =~ s/;.*$//g;
@input_vars_array = split( /,/, $tmp_vars );
push @target_vars_array, [ @input_vars_array ] unless ( /^\W/ );
}
close IN_FILE;
for my $counter ( 0 .. $#target_vars_array ) {
$user = $target_vars_array[$counter][0];
$pass = $target_vars_array[$counter][1];
$machine = $target_vars_array[$counter][2];
$mount = $target_vars_array[$counter][3];
print "$user, $pass, $machine, $mount\n";
$mount_result = qx#/bin/mount#;
if ( $mount_result =~ /$machine\/documents/ ) {
print "$machine: already mounted\n";
}
else {
$mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
/mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
password=$pass#;
}
print "$mount_result\n";
}
exit
the simple concept of escaping a "backslash", thus translating to a
literal backslash; does not provide the implied result, under the
following example.
$mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
/mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
password=$pass#;
The top part of the "strace" output gives this:
execve("/bin/mount", ["/bin/mount", "-t", "smbfs", "\\an2documents",
"/mnt/workstation_shares/xxxx/doc"..., "-o", "ro", "-o",
"username=xxxx", "-o", "password=xxxxxxxxxx"], [/* 22 vars */]) = 0
"\\an2documents"
Note; that there is no "\" in between the machine name, and the share.
It should be "\\an2\documents".
[root@mercedes sbin]# perl -e 'print "\\\\an2\\documents\n"'
\\an2\documents
I'm sure it's a simple thing, but can someone enlighten me on this
parlay?
ta.
Full Context
===============================================================================
#!/usr/bin/perl
use strict;
use warnings;
my $input_vars_file = "/usr/local/etc/priv/users_test";
my $tmp_vars;
my $input_vars;
my @input_vars_array;
my @target_vars_array;
my $user;
my $pass;
my $machine;
my $mount;
my $mount_result;
open ( IN_FILE, "< $input_vars_file") or die "$!";
while ( <IN_FILE> ){
$tmp_vars = $_;
$tmp_vars =~ s/(\s+)/,/g;
$tmp_vars =~ s/;.*$//g;
@input_vars_array = split( /,/, $tmp_vars );
push @target_vars_array, [ @input_vars_array ] unless ( /^\W/ );
}
close IN_FILE;
for my $counter ( 0 .. $#target_vars_array ) {
$user = $target_vars_array[$counter][0];
$pass = $target_vars_array[$counter][1];
$machine = $target_vars_array[$counter][2];
$mount = $target_vars_array[$counter][3];
print "$user, $pass, $machine, $mount\n";
$mount_result = qx#/bin/mount#;
if ( $mount_result =~ /$machine\/documents/ ) {
print "$machine: already mounted\n";
}
else {
$mount_result = qx#strace /bin/mount -t smbfs \\\\$machine\\documents
/mnt/workstation_shares/$mount/documents/ -o ro -o username=$user -o
password=$pass#;
}
print "$mount_result\n";
}
exit