From: kath on 16 Feb 2007 04:45 Hello, 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? Thank you, Regards, kath.
From: Mirco Wahab on 16 Feb 2007 05:23 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.
From: Tad McClellan on 16 Feb 2007 07:04 Mirco Wahab <wahab-mail(a)gmx.de> wrote: > Under Unix, you need to have access to the > windows box by smbclient and fiends. ^^^^^^ Did you do that on purpose, or is it an (entertaining) Freudian slip? :-) -- Tad McClellan SGML consulting tadmc(a)augustmail.com Perl programming Fort Worth, Texas
From: Mirco Wahab on 16 Feb 2007 09:28 Tad McClellan wrote: > Mirco Wahab <wahab-mail(a)gmx.de> wrote: > >> Under Unix, you need to have access to the >> windows box by smbclient and fiends. > ^^^^^^ > > Did you do that on purpose, or is it an (entertaining) Freudian slip? > > :-) Ooops, sometimes I'd really try hard to be "funny" - but here I was just typing during a telephone conversation with someone else ... Sorry ;-) M.
From: Ala Qumsieh on 16 Feb 2007 20:49 Tad McClellan wrote: > Mirco Wahab <wahab-mail(a)gmx.de> wrote: > >> Under Unix, you need to have access to the >> windows box by smbclient and fiends. > ^^^^^^ > > Did you do that on purpose, or is it an (entertaining) Freudian slip? Very often I forget the 'f' in code like this: my $arg = shift; fortunately, strict doesn't like filthy code. --Ala
|
Next
|
Last
Pages: 1 2 Prev: Net::SSH::Perl - Channel open failure? Next: how to handle Multi Value Hash output? |