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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open (Dir...) 1

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
US
hi people,

thanks for your help in advance. i have saved the following code on a server and when i try to run, it gives this error

No such file or directory at D:\Montana\Fails\test.pl line 8.

(D:\ is the server)

and the script is
use strict;
use warnings;

open (FH, "C:\\\\Test\\61012049.ver") or die $!;
print while (<FH>);

where (C:\ is the hard drive on my pc). How can I show the server that the file is located on another machine? The "other machine" s hard drive C: is mapped on the server. the task i want to accomplish is much more complicated but i think if i resolve this problem, i will complete the other one. thanks for your help in advance!
 
Hi,
I cannot see line 8 in your script. However, if your local drive is mapped as Z: on your server, try :
Code:
open (FH, "Z:\\Test\\61012049.ver") or die $!;

instead of :

Code:
open (FH, "C:\\\\Test\\61012049.ver") or die $!;

Is it as simple as that ?
 
I think the problem is that you have 4 backslashes after C: instead of 2. You may find it easier to just use forward slashes, then you don't have to escape them:

open (FH, "C:/Test/61012049.ver") or die $!;

As for opening files on another server, you can either use the mapped drive letter, or the UNC path name - I suggest using UNC to ensure it will work on any machine no matter what letter the folder is mapped as.
In explorer, you should see mapped folders as:

Folder on 'fileserver01'(G:)

where fileserver01 is the computer name, so something like this should work:
open (FH, "//fileserver01/path/to/Folder/61012049.ver") or die $!;

UNC paths are always preceded by two backslashes, or you can use the forward slash method.
 
hey guys,
i really appreciate for your help. some guy in another forum told me that i couldn't use UNC paths. that's what i wanted to do in the first place. anyway, i changed that line to

open (FH, "//servername/tnb1/OUT/61012049.ver") or die $!;

now i receive this error

Permission denied at D:\Montana\Fails\test.pl line 8.
again D: is the server called hestia. i am actually trying to read 1500+ text files on another server called "tnb1". these are all in the same domain called "autos" do i need to include the domain name as well? we looked to check the read/write permissions and it says that anyone can read those files in servername/tnb1/out folder.
 
I'm not sure what's causing that.. Are you sure the UNC path is correct? Just try pasting the path \\servername\tnb1\OUT\ into the address bar in explorer and see if it brings you to the correct folder.
I use this method regularly across domains with no problems, but there could be differences in your network configuration that are causing problems.
 
when i copied and pasted
\\servername\tnb1\OUT\
it brings up another window showing what's inside. so, what i should do?
 
Try something like this
Code:
chdir($Path) ||
  die "Cannot change directory to $Path: $!";
opendir(directory,".") ||
  die "Cannot open the directory . (Directory may not exist): $!";

$i = 0;
foreach $file ( readdir(directory)) {   
  	@files[$i] = "$file\n";  	
  	$i++; 
  	}
closedir(directory);
 
i dont know. i did what you told me and know i get

cannot change directory to \\novardb1\tnb1\OUT: No such file or directory at D:\Montana\Fails\test1.pl line 5.

 
use a test directory on your local machine...

something like

Code:
$Path = 'C:\\'

and see if that works first then move on to the other network drives
 
everything works on my local machine. i can reach to other server T:\out or "\\novardb1\tnb1\out" without any problem. i encounter these errors when i move this script on another server and try to run it from there.
 
Did you try mapping the network drive on the server you're running the script from so it can see it as T: as well
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
yes sir, the novardb1/tnb1 is mapped and the other server sees it as 'T:'
 
something just came up to my mind. my files are saved under
\\hestia\montana\fails\ or ' d:\montana\fails'
is it possible that i try to reference 'T:\OUT\VERIFS' while working under 'D:\montana\fails' ?
i just tried something on MS-DOS
when i am under

C:\Documents and Settings\btoker3147>cd T:\OUT\VERIFS
then hit enter
nothing happens. will it be something related to my problem?
thanks for all your help
 
In that case, if you then type C:\Documents and Settings\btoker3147>T:
<enter>
you should now be at T:\OUT\VERIFS>

If you're using absolute paths in the script this shouldn't be a problem though
 
Yes, it is possible to reference a directory from another drive. What happened on your command window is you changed directory to t:\out\verifs. You should then change the drive to t: to get into this directory.
Code:
C:\Documents and Settings\btoker3147>cd T:\OUT\VERIFS 
[enter]
C:\Documents and Settings\btoker3147>t:
[enter]
T:\OUT\VERIFS>
Are you sure read permissions and also sharing properties of the "\\servername\tnb1\OUT\" folder are ok, may be the connections number is limited, or web server user cannot access either the folder or the file ?
 
Thanks for all your help! After talking to another programmer, I will need to check the security permissions and privileges on both of these servers. however, since i am new at this, I don't exactly know what to look for. Does anyone of you encounter a similar problem before? Where do you find security permissions and privileges ?
thanks once again
 
On the server, logged in as Administrator, right click the drive which is shared, and select properties, and you should see a sharing tab, which will have permissions, and groups and the like

see for more details

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Thanks, I checked that out the connection works fine between two servers.
Another question i have is that i have
perl, v5.8.1 built for MSWin32-x86-multi-thread
(with 1 registered patch
and perl v5.6.1.3.5 on the server. will it be possible for a script to run on my machine and not run on the server because the vers are different?
 
*Shouldn't* be a problem, but suck it and see, and if you come across a problem, you could probably reimplement another way of doing the "unsupported" functions
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Well, it turns out the IIS server on one of these servers didn't give me permission to access the files on another server. My next question is, do i need to setup the IIS server in a way that it will create some tables in SQL server 2000?
i am using

my $DSN = 'driver={SQL Server};Server=HESTIA;database=VerifDB;uid=sa;pwd=password';
my $dbh = DBI->connect("dbi:ODBC:$DSN",'sa','password') or die "$DBI::errstr\n";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top