Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Unix folder in Perl on windbows based 2

Status
Not open for further replies.

vietboy505

Technical User
Feb 20, 2006
56
US
Code:
#!/usr/local/bin/perl5

use Cwd;

print("Current directory: ");
print(cwd());
print("\n");
chdir("/home/users/vietboy/");
print("\n");
print("Current directory 2: ");
print(cwd());
print("\n");
How can I bypass to go to the unix directory on the window based?
 
Can you rephrase your question? I don't understand what you're looking for.
 
Code:
chdir("/home/users/vietboy/");

I was trying to access the following directory in PErl from the windows side. I was wondering if I can get into that directory from the window side, not from unix.
 
Chdir will only work for directories on the local filesystem. Unless you have that directory mounted on your Windows system (e.g. by using Samba and mounting it as a shared folder), you won't be able to access it from another machine.
 
I do have Samba running.
I was thinking about writing a config file to pass the right path to that script.

How would I do that:

mount.pl
Code:
#!/usr/local/bin/perl

use Cwd;

print("Current directory: ");
print(cwd());
print("\n");
#chdir("/home/users/vietboy/"); unix side
# \\vietboyserver\home\users\vietboy\
chdir("\\\\vietboyserver\\home\\users\\vietboy\"); #got it map
print("\n");
print("Current directory 2: ");
print(cwd());
print("\n");

output: work!
Code:
Current directory: C:/vietboy/perl/script

Current directory 2: //vietboyserver/home/users/vietboy

Some other script I wrote that have a variable like
Code:
$vietboy_path="/home/users/vietboy/";
$other_path="/homer/users/other/";

How would I achieve it by using the another config file?
 
I use

Code:
require "config.file";
where all the scripts need to access to the path?

and in config.file have:
Code:
$vietboy_path="\\\\vietboyserver\\home\\users\\vietboy\/";
$other_path="\\\\vietboyserver\\home\\users\\other\";
 
I change my mind, I want to use this instead.

config.pl
Code:
#!/usr/local/bin/perl

$vietboy="\\\\vietboyserver\\home\\users\\vietboy\\";
$other="\\\\vietboyserver\\home\\users\\other\\";

if ($ARGV[0] eq vietboy) {
	return chomp($vietboy);
} elsif ($ARGV[0] eq "other") {
	return chomp($other);
} else {
	print("wrong user $_ ");
}

for a test script:

Code:
#!/usr/local/bin/perl

$vietboy = `config.pl vietboy`;

use Cwd;

print("Current directory: " . cwd() . " \n");
chdir($vietboy);
print("Current directory 2: " . cwd() . " \n");

The output doesn't change the path at all. I think it's the if statement in config.pl?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top