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

Checking Files on Remote Servers

Status
Not open for further replies.

CoryMa2c

Technical User
May 31, 2005
10
US
Hello,

I am trying to get a file listing of a directory on a remote server. Right now I am using File::Find:name, which works great on the local computer, but always produces an error message for each file it lists on the remote server. I don't have the error message in front of me, but it says something like, "\\$RemSrv is unknown, using local host". However, it seems to work on the remote server, but is a) really slow and b) the error messages are annoying. Is there a better way to list the files on a remote server?

Code:
#$RemSrv = remote server FQDN
$workingDir = "c:\\temp";
use File::Find;
foreach (@Dir) {
	($dir = $_) =~ s{:}{\$}g;
	#print "$dir \n";
	chomp ($where = `echo $RemSrv\\$dir`);
	#print "$where \n";
	find (\&echoecho, "$where");
	sub echoecho (){
		($filename = $File::Find::name) =~ s{/}{\\}g;
		($fileV1 = $filename) =~ s{\\$RemSrv\\}{}g;
		($fileV2 = $fileV1) =~ s{\$}{:}g;
		system "echo $fileV2 >> $workingdir\\FileList.txt";
	}
}

Any help is appreciated.
Thanks,
- C
 
Is this all of your code?


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Hello CoryMa2c,

File::Find is for filesystems that look local.

If you need to search a filesystem on a remote server you will need to map a drive letter to it so that it appears to be a local disk-drive rather than use the \\server notation.

Mike

You cannot really appreciate Dilbert unless you've read it in the
original Klingon.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
If you're looking to not keep a drive mapping on the user's computer all the time, you could run the 'Net Use' command in Windows to map the drive, then process your files and disconnect from the mapped server.

Net Use Help said:
The syntax of this command is:


NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


NET USE connects a computer to a shared resource or disconnects a
computer from a shared resource. When used without options, it lists
the computer's connections.

devicename Assigns a name to connect to the resource or specifies
the device to be disconnected. There are two kinds of
devicenames: disk drives (D: through Z:) and printers
(LPT1: through LPT3:). Type an asterisk instead of a
specific devicename to assign the next available
devicename.
\\computername Is the name of the computer controlling the shared
resource. If the computername contains blank characters,
enclose the double backslash (\\) and the computername
in quotation marks (" "). The computername may be from
1 to 15 characters long.
\sharename Is the network name of the shared resource.
\volume Specifies a NetWare volume on the server. You must have
Client Services for Netware (Windows Workstations)
or Gateway Service for Netware (Windows Server)
installed and running to connect to NetWare servers.
password Is the password needed to access the shared resource.
* Produces a prompt for the password. The password is
not displayed when you type it at the password prompt.
/USER Specifies a different username with which the connection
is made.
domainname Specifies another domain. If domain is omitted,
the current logged on domain is used.
username Specifies the username with which to logon.
/HOME Connects a user to their home directory.
/DELETE Cancels a network connection and removes the connection
from the list of persistent connections.
/PERSISTENT Controls the use of persistent network connections.
The default is the setting used last.
YES Saves connections as they are made, and restores
them at next logon.
NO Does not save the connection being made or subsequent
connections; existing connections will be restored at
next logon. Use the /DELETE switch to remove
persistent connections.
NET HELP command | MORE displays Help one screen at a time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top