473,769 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access UNC Windows path using variable as server name

3 New Member
I am trying to access files on a remote windows server using the following code;
Expand|Select|Wrap|Line Numbers
  1. my $node = 'server5';
  2. opendir(DIR, '\\$node\C$\Servers') or warn "open failed. reason: $!";
  3.  
I get an error; open failed. reason: no such file or directory at ... line xx.

If I place the node name in place of the $node, it works fine.
Expand|Select|Wrap|Line Numbers
  1. opendir(DIR, '\\server5\C$\Servers') or warn "open failed. reason: $!";
  2.  
And yes, $node = 'server5';

I am running this from Windows Server 2003 and all of the servers I am trying to connect to are windows servers as well.

I have also tried "\\\\$node\\C$\ \Servers" and '//$node/C$/Servers' and "//$node/C$/Servers" all with the same error as above.

Please respond to <REMOVED BY MODERATOR>

Thanks,

Rob
Jun 5 '07 #1
4 7962
miller
1,089 Recognized Expert Top Contributor
Greetings Rob,

You're using a single quoted string which does not allow interpolation. Whenever working with directories or files, it often helps to assign the directory or file name to a variable before using it in an opendir or open statement. This is useful since it allows you to also include the same file or directory name in your error checking statement, which would have clued you into the problems.

Expand|Select|Wrap|Line Numbers
  1. my $node = 'server5';
  2. my $dir = "\\\\$node\\C\$Servers";
  3. opendir(DIR, $dir) or die "Can't open $dir: $!";
  4.  
Now, I don't know what path you are trying to open, so I can't really advise you on what the syntax of $dir should be. But this methodology should at least let you attempt to get it working right. Good luck.

- Miller
Jun 5 '07 #2
roblenator
3 New Member
Thank you thank you thank you!!!

The problem was my C$ needed to be C\$.

So, the syntax opendir(DIR, "\\\\$node\\C\$ \\Servers") is the correct syntax.
Jun 5 '07 #3
miller
1,089 Recognized Expert Top Contributor
Glad I could help.

- Miller
Jun 5 '07 #4
KevinADC
4,059 Recognized Expert Specialist
Thank you thank you thank you!!!

The problem was my C$ needed to be C\$.

So, the syntax opendir(DIR, "\\\\$node\\C\$ \\Servers") is the correct syntax.

That is the correct syntax, but \$ was only part of the problem. As Miller pointed out, you were using single-quotes to construct the string, when you needed to use double-quotes.
Jun 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4753
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
7
8869
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
11
6600
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
4
2917
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached below). I suppose I have some kind of permissions issue on the server? What recommendations can anyone propose? Thanks, -- Bruce
1
4895
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is denied. Here is the server setup that we have: Dev - Development Computer on WinXP Pro SP2 (IIS5), VS2003 developing under .NET Framework 1.1 Server1 - Web Server on Win2003 Server (IIS6) Server2 - File Server on Win2003 Server
10
4065
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to Pop up windows Authentication box so that user will give his userId, Password & domain name for authenticaion. After that I want to take these three info of user and make a search in Active Directory.
1
3111
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the completed job. I can create a hyperlink button that will link to a photgraph, but I cannot link to a specific photo of that specific job. Each job has its' own unique identifier, I call it the GOTC number. It is a separate field in the table of installed...
4
2783
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields (fromStop) and its associated driving directions back to a relational database. I have asked my software vendor for solutions but thus far they have not come up with anything. I am totally unfamiliar with XML so I am struggling with how to do this. I have...
24
5080
by: dancer | last post by:
Using ASP.net 1.1 and Microsoft Access. I received the following error message. Why? I have closed the Access file. I have another very small access file that opens with no trouble with the same code, except a different name for the file. The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\Accident.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
25
3014
by: p byers | last post by:
Good Morning Folks I have a LAN Among the several connections to it are the following four devices: A MAXSTOR network Storage Device A PC running Microsoft Windows 2000 Server 5.0.2195 (SP4) A PC running Microsoft Windows XP Professional 5.1.2600 (SP2) A PC running Microsoft Windows XP Professional 5.1.2600 (SP2) All of the PCs are running IIS
0
10205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.