From: kath on 16 Feb 2007 21:59 On Feb 16, 3:23 pm, Mirco Wahab <wahab-m...(a)gmx.de> wrote: > kath wrote: > > I have a script to read remote file. The script goes as follows, > > #!C:\Perl\bin\perl.exe > > $remote= '\\\remotehost\remotedir\remotefile.jml'; > > open(fp, $remote) or die ("could not open the file"); > > print while(<fp>); > > close(fp); > > This script runs fine on my windows machine. But the same script when > > I run in UNIX, after changing the shebang line to /usr/bin/perl, I > > get > > could not open the file file_name.pl at 4 > > > The remote host from which I am trying to read the file is also > > Windows box. > > 1. where am i making wrong? > > 2. Why the script is not running on UNIX? > > Under Unix, you need to have access to the > windows box by smbclient and fiends. > > Your code traanslated to the unix world > could read like the following: > > use strict; > use warnings; > > # this is what you used to use > my $winrmt = '\\\remotehost\remotedir\remotefile.jml'; > > # make sure you get the access rights correct, > # maybe you can drop username/password completely > my $unxrmt = '-n --username=kath --password=kath01 smb:/' > . join '/', split /\\+/, $winrmt; > > # pull some adrenaline: > print "trying: $unxrmt \n"; > > my $pid = open HANDLE, "smbget $unxrmt |" or die "fork error: $!"; > close HANDLE; > > # now your remote file should reside in your current > # directory. Please check out other options if the > # smbclient family e.g.: $> man smbget > > If it won't work, check out what $unxrmt looks like > and pot it back here ... > > Regards > > M. hi, I do not see the post I done before, so i am reposting, Hi Wahab, thanks for the reply. I was not aware of the smb* commands. You made me to learn this new command. The output of $unxrmt was correct, and tried to run the same at console(command-prompt) but I get, You don't have enough permissions to access smb://remotehost/remotedir/remotefile.jml but when use the same( open(filehandle, remotefile) ) function I do not get message like, you don't have enough permission. Its expecting the username and password. Why that don't ask when I try access the same location on Windows, though I was not using smbclient family commands on windows. Do i need to download the file(s) first prior reading it(I do not do that, as you can see in the above code )? Thanks, Regards, kath.
From: Joe Smith on 18 Feb 2007 04:10 kath wrote: > You don't have enough permissions to access smb://remotehost/remotedir/remotefile.jml That usually means you did not provide the right credentials (username + password). > Why that don't ask when I try access the same location on Windows, On Windows, it remembers the password you used to log into the system with, and provides your username and password whenever accessing a remote server's file share. Unix is not Windows. Your Windows username and password have no meaning for Unix. You have to provide your credentials to whatever Unix is using to access the Windows file share. > though I was not using smbclient family commands on windows. You're using the SMB protocols every time you use the UNC (Uniform Naming Convention or UNC) such as "\\remotehost\sharename\remotefile". > Do i need to download the file(s) first prior reading it(I do not do > that, as you can see in the above code )? Unix has its own naming conventions - it does not use the Windows UNC. Unless you have root (Administrator) privileges on Unix, you cannot expect to be able to access a Windows file share as a Unix file system. You'll have to fetch the data from the Windows file and store it as a Unix file, or open a piped command and read the data sequentially. -Joe
First
|
Prev
|
Pages: 1 2 Prev: Net::SSH::Perl - Channel open failure? Next: how to handle Multi Value Hash output? |