How Can I Use "getOpenFile" for remote machine files???????????

This is a discussion on How Can I Use "getOpenFile" for remote machine files??????????? within the Perl forums in Programming Languages category; Hi All, I am stuck with problem of, I want to browse files in remote machine using "getOpenFile". How Can I Use?? Here is my Sample Code, use IO::Ftp; use Tk; my $server = 'blahblahblah'; my $user = 'blahblah'; my $pwd = '123'; my $ftp = Net::FTP->new($server); $ftp->login($user,$pwd); $ftp->binary(); my @files= $ftp->ls() or die "Can't List Files\n"; my $mw = new MainWindow; my $Types = [ ['mpg files',['*.mpg']] ]; my $open = $mw->getOpenFile( -filetypes => $Types, -initialdir => $ftp->ls()); if($open) { print "\$open = $open\n"; } __________________________________________________ ____________________________________ I am getting Error as, Tk::Error: Can't use string ("") as a ...

Go Back   Application Development Forum > Programming Languages > Perl

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-08-2008, 06:10 AM
g.vikramkumar@gmail.com
Guest
 
Default How Can I Use "getOpenFile" for remote machine files???????????

Hi All,
I am stuck with problem of, I want to browse files in remote machine
using "getOpenFile".
How Can I Use??

Here is my Sample Code,


use IO::Ftp;
use Tk;

my $server = 'blahblahblah';
my $user = 'blahblah';
my $pwd = '123';


my $ftp = Net::FTP->new($server);
$ftp->login($user,$pwd);
$ftp->binary();


my @files= $ftp->ls() or die "Can't List Files\n";


my $mw = new MainWindow;
my $Types = [ ['mpg files',['*.mpg']] ];


my $open = $mw->getOpenFile(
-filetypes => $Types,
-initialdir => $ftp->ls());

if($open)
{
print "\$open = $open\n";
}

__________________________________________________ ____________________________________


I am getting Error as,

Tk::Error: Can't use string ("") as a subroutine ref while "strict
refs" in use at /usr/local/lib/perl/5.8.8/Tk/FBox.pm line 439.
and so on...

How Can I Solve this.

Any Help will be appreciated..........





Reply With Quote
  #2  
Old 09-08-2008, 07:33 AM
Josef Moellers
Guest
 
Default Re: How Can I Use "getOpenFile" for remote machine files???????????

g.vikramkumar@gmail.com wrote:
> Hi All,
> I am stuck with problem of, I want to browse files in remote machine
> using "getOpenFile".
> How Can I Use??
>
> Here is my Sample Code,
>
>
> use IO::Ftp;
> use Tk;
>
> my $server = 'blahblahblah';
> my $user = 'blahblah';
> my $pwd = '123';
>
>
> my $ftp = Net::FTP->new($server);
> $ftp->login($user,$pwd);
> $ftp->binary();
>
>
> my @files= $ftp->ls() or die "Can't List Files\n";
>
>
> my $mw = new MainWindow;
> my $Types = [ ['mpg files',['*.mpg']] ];
>
>
> my $open = $mw->getOpenFile(
> -filetypes => $Types,
> -initialdir => $ftp->ls());
>
> if($open)
> {
> print "\$open = $open\n";
> }
>
> __________________________________________________ ____________________________________
>
>
> I am getting Error as,
>
> Tk::Error: Can't use string ("") as a subroutine ref while "strict
> refs" in use at /usr/local/lib/perl/5.8.8/Tk/FBox.pm line 439.
> and so on...
>
> How Can I Solve this.


By checking whether the various object initializers succeed:

my $ftp = Net::FTP->new($server) or die "Failed to connect to $server: $@";
....
my $mw = new MainWindow or die "Cannot open Window: $@";


--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
Reply With Quote
  #3  
Old 09-08-2008, 08:17 AM
zentara
Guest
 
Default Re: How Can I Use "getOpenFile" for remote machine files???????????

On Mon, 8 Sep 2008 03:10:19 -0700 (PDT), g.vikramkumar@gmail.com wrote:

>Hi All,
>I am stuck with problem of, I want to browse files in remote machine
>using "getOpenFile".
>How Can I Use??
>Here is my Sample Code,


Besides the other errors in your script,
I don't think you can use getOpenFile on remote filesystems.
getOpenFile is meant for locally mounted filesystems, like
your own machine, or (guessing) possibly network mounted
filesystems, like thru Samba or NFS on linux.
Ftp connections are done thru a remote server.

What you need to do, is after the my @files = $ftp->ls(),
$ftp->get($your_file), then open the file once you get it
locally.

>my @files= $ftp->ls() or die "Can't List Files\n";


get all files in @files with $ftp->get

Now they are local
>my $mw = new MainWindow;
>my $Types = [ ['mpg files',['*.mpg']] ];
>
>
>my $open = $mw->getOpenFile(
> -filetypes => $Types,
> -initialdir => $ftp->ls());
>
>if($open)
>{
> print "\$open = $open\n";
>}
>
>_________________________________________________ _____________________________________
>
>
>I am getting Error as,
>
>Tk::Error: Can't use string ("") as a subroutine ref while "strict
>refs" in use at /usr/local/lib/perl/5.8.8/Tk/FBox.pm line 439.
>and so on...
>
>How Can I Solve this.
>
>Any Help will be appreciated..........
>
>
>
>


--
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html
Reply With Quote
  #4  
Old 09-08-2008, 02:35 PM
smallpond
Guest
 
Default Re: How Can I Use "getOpenFile" for remote machine files???????????

On Sep 8, 6:10 am, g.vikramku...@gmail.com wrote:
> Hi All,
> I am stuck with problem of, I want to browse files in remote machine
> using "getOpenFile".
> How Can I Use??
>
> Here is my Sample Code,
>
> use IO::Ftp;
> use Tk;
>
> my $server = 'blahblahblah';
> my $user = 'blahblah';
> my $pwd = '123';
>
> my $ftp = Net::FTP->new($server);
> $ftp->login($user,$pwd);
> $ftp->binary();
>
> my @files= $ftp->ls() or die "Can't List Files\n";
>
> my $mw = new MainWindow;
> my $Types = [ ['mpg files',['*.mpg']] ];
>
> my $open = $mw->getOpenFile(
> -filetypes => $Types,
> -initialdir => $ftp->ls());
>
> if($open)
> {
> print "\$open = $open\n";
>
> }
>
> __________________________________________________ ____________________________________
>
> I am getting Error as,
>
> Tk::Error: Can't use string ("") as a subroutine ref while "strict
> refs" in use at /usr/local/lib/perl/5.8.8/Tk/FBox.pm line 439.
> and so on...
>
> How Can I Solve this.
>
> Any Help will be appreciated..........



Only works on mounted filesystems, which is possible to do.
You can mount filesystems over FTP, just like over SMB or NFS.
On Linux, it requires curlftpfs. Then you don't need the
FTP module.

--S
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:26 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.