473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access UNC Windows path using variable as server name

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 7936
miller
1,089 Expert 1GB
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
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 Expert 1GB
Glad I could help.

- Miller
Jun 5 '07 #4
KevinADC
4,059 Expert 2GB
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
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...
7
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...
11
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...
4
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...
1
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...
10
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...
1
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...
4
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...
24
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...
25
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.